1

I am developing an interactive web application with ASP.NET Core MVC.

The application consists of reading several items of data from a JSON file, nested in the following way:

Communities --> People --> People data 

I have already developed the model, the controller and the view, and I am able to show a grid containing the names of the people available in the JSON file, using this technique from NewtonSoft :

string json = webClient.DownloadString(@"MyJson.json");
model.RootObjects = JsonConvert.DeserializeObject<Rootobject>(json);

My question: I would like to add a popup/window, upon clicking one of the buttons/data cells that contain the person name in the grid. Upon clicking the modal must show further information from the same Json file that has been used to build the Main Grid (in the index) .

The complexity that I am facing (As I am really new to this kind of dev) is : having multiple dynamic buttons (created from the Json data) then synchronizing between the ID of the button (Or Data cell) and the Specific information being read again from the JSON and returned to the model.

I have tried a lot of solutions which I have found on different websites, I have seen JQuery, AJAX . Tried to build another model for a partial view, but in vain .

I only need some suggestions from your experience. What is the best that you could do in this kid of situations?

Should I go again through developing a new model in my ASP.NET Core MVC and reinvent the wheel? Should I go through pure AJAX, jQuery ...etc ?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • I would base my approach on how much data is involved. Does the JSON you pull down initially have ALL the detail you need? How many details do you need at each level of the navigation (2-3 strings or arrays of more data)? The question becomes, do you want to pull a bunch of data you don't need, or only pull data as you need it? – flashsplat Aug 26 '22 at 15:44
  • If its small amounts of data (2-3 values), you can embed that in the table elements. Anything more and I'd suggest modifying the first JSON call to only pull back what you need to build the table, and then make AJAX calls to get more data as required. This is simply an opinion on the matter. Only you know its true use case, available bandwidth, etc. – flashsplat Aug 26 '22 at 15:51
  • @flashsplat: The JSON I am dealing with hass all the details I need, either for the table in the index page, or the popup, for both I will be using the same JSON, it is also only some few data, like 2-3 strings, for the popup. – Macadamia1988 Aug 28 '22 at 15:08
  • Exactly that is the point, I would like to build the whole main table at first, using the whole JSON. after that pull the small data I need form the JSON again using AJAX, The difficulty here, is that I do not know how to synchronize between the element which has been clicked inside the table , and the AJAX call, In other word, how can I pass the unique ID of the element to the JS ? Also, would it be necessary to add additional code to the controller ? I am lost in the architectrure here, as I am coming form pure embedded development world. – Macadamia1988 Aug 28 '22 at 15:11

0 Answers0