14
I used this solution because when trying to render a Table in a view with many records the user’s browser gave Crash, I know it is a solution not much elegant but it was the only solution that came to mind. (In this view I have to load all the records on the screen to the user)
I created a method Gerartabela where I populate with the database data and return a String with HTML containing the data. In the View call I make an Ajax request that assemble the table pro user, basically do the rendering on the server-side.
What are the disadvantages of using this model and what alternative could be adopted? 1
Prototype:
1 On this page I cannot use pagination, all records must be loaded at once.
This table is for viewing and user actions only or is related to reports?
– Trxplz0
For visualization and interaction of some of the fields. I attached the screen prototype the question for a better understanding.
– anon
With the request being made by ajax the browser is crashing?
– Premiere
No. My View was typed and received a list (I made an Ajax request too, only the return was a List), so I rendered using Razor (in this case I crashed). Now I make an Ajax request and give an innerHTML in the table (the result of my request is HTML already with populated values, Razor’s responsibility previously).
– anon
To optimize this process you can select only the fields that will be displayed in this table. As for the view part I believe it makes no difference as both are processed on the server-side and with the ajax request you have the benefit of keeping the page responding!
– Premiere
I was already doing it man, the return of my list was just these 4 fields that you can see in the prototype.
– anon
How many records are you returning ?
– Premiere
4,000 records.
– anon
Let’s go continue this discussão in chat.
– Premiere
Using Ajax does not assume that the HTML will come from the controller. You can make a request via ajax, exactly as you are doing, and it returns the HTML exactly as you are doing, but instead of the controller generating the html, it switches to the render view. A request with Ajax works exactly like a request without ajax, that is, it can have its own view and its js can write the text directly on the screen. Now if the browser is locking by the amount of data, I don’t know exactly how ajax is helping, unless you are implementing a Lazy load scheme. This is the case?
– Luís Henrique Faria
Your save button is not working, I kept clicking several times and did not save anything :(
– RodrigoBorth
@Rodrigoborth lol
– anon
@Luíshenrique It is because first I load the page then I make a request that searches a list and then returns the HTML with all the formatted tags, I only make the request for Ajax to give an "Append" of the HTML on the page returned from the Controller.
– anon
Well, if you say it improves, beauty. But, anyway, your controller does not need to return html. I don’t use ASP, but I imagine it has a way to do what I’m saying: what if the URL X (from where you take the data) had a simpler template containing only the table you need? It would have a view, where HTML would be and you would keep working, from the point of view of the page that requests the data, in exactly the same way.
– Luís Henrique Faria
Dude, I already tried this, before my screen had only the table structure and a foreach pro Razor popular the data that came in the list, my view was typed, I could understand?
– anon