I'm setting up a jqGrid (in a Google Chrome Extension) which will handle local JSON data.
My concern is performance due to my unique use case. I have thousands of records getting dynamically generated on the client side over a few minutes and I can't wait for the data to be generated so currently I add this data to the grid row by row using 'addRowData'.
But the problem is, when I'm adding data to the grid I have to check if that data already exists and if it does I need to update the existing record. I'm just having trouble understanding the best way to accomplish this, is the only way I can search the grid by calling 'getCol' and then searching the array. My concern with calling getCol is I presume this searches the DOM? But I could be wrong, I have scroll: 1 set and I'm starting to think this might mean its pulling data directly from an array?
Or maybe I should be implementing this a totally different way? It would of been so much easier if I could of just inserted all of this data into an array and then loaded the grid but due to the time taken to generate the data the user needs to see it ASAP.
Related
Binding MVC grid to stored procedure with large amount of data:
I want to bind MVC grid to an object result that returned from SP
Normally the grid request only data needed to be shown to the user and that will be very good when binding to a table with large amount of data that lets the grid fast and its performance would be good.
i have 2 ways to bind MVC grid with SP:
Bind to SP without using .ToList() it gives me an error "The result of a query can not be enumerated more than once."
Bind to sp using .ToList() will resolve that error but it will loads all records from database first and the performance will be bad and the grid loading, paging, sorting and filtering would be very slow.
Please tell me a solution to bind MVC grid with SP that returns large amount of data with good performance.
Thank you
I have used jqgrid in the past, jqgrid implements paging so not all the content of the grid is actually displayed at once, you pick the number of rows per page and jqgrid automatically will hook the navigation to your controller. There are a lot of examples of this on the web. If you click the next page it will retrieve the appropriate data for that page and so forth.
The jqgrid page has a lot of examples in loading data that ilustrate this: http://www.trirand.com/blog/jqgrid/jqgrid.html, here is another page that talks how that is implemented at the server side using mvc http://www.codersource.net/AspNet/ASPNetAdvanced/jqGridPaginginaspnetmvc.aspx, I'm sure if you look around you'll find a lot of information on how to go about this approach.
Finally I usually avoid showing the user a lot of data anyways, mainly because it is hard for a human been to make any sense of more than 100 rows of data having a way to search further in it. So I rather try and attempt to shrink the data size giving them a way to filter it down further, but this is not always possible.
Hope this helps.
,This question is likely subjective, but a lot of "grid" Javascript plugins have come out to help paginate and sort tables. They usually work in 2 ways, the first and simplest is that it takes an existing HTML <table> and converts it into a sortable and searchable information. The second is that it passes info to the server and has the server select info from the database to be displayed.
My question is this: At what point (size wise) is it more efficient to use server-side processing vs displaying all the data and have the "grid plugin" convert it to a sortable/searchable table client-side?
Using datatables as an example, I have to execute at least 3 queries to get total rows in the table, total filtered results for pagination, and the filtered results to be displayed for the specific selected page. Then every time I sort, I am querying again. Every time I move to another page, or search in the table, more queries.
If I was to pull the data once when the client visits the page, I would be executing a single query, and then formatting and pushing the results to the client all at once. This increases the page size, and possibly delays loading of the page once it gets too big. The upside is there will only one query, and all the sorting, searching, and pagination is handled by the plugin, so no waiting for a response and no more queries.
If I was to have just a few rows, I imagine just pushing the formatted table data to the client at the page load would be the fastest. But with thousands of rows, switching to server-side would be the most efficient way.
Where is the tipping point? Is there a tipping point, or is server-side or client-side the way to go 100% of the time?
The answer on your question can be only subjective. So I explain how I personally understand the problem and give me recommendation.
In my opinion the data with 2-3 row and 3-4 column can be displayed in HTML table without usage any plugin. The data you display for the user the more important will be that the user will be able to grasp the information which will be displayed. So I think that the information for example have to be good formatted and marked with colors and icons for example. This with help to grasp information from probably 10 rows of data, but not much more. If you just display table with 100 rows or more then you overtax the user. The user will have to analyse the data to get any helpful information from the table. Scrolling of the data makes this not easier.
So I think that one should give the user comfortable or at least convenient interface to sort and to filter the data from the table. The exact interface is mostly the matter of taste. For example the grid can have an additional filter bar
For filtering and even for sorting of the data it's important to have not pure strings, but to be able to distinguish the data types like integer (10 should be after 9 and not between 1 and 2), numbers (correct interpret '.' and ',' inside of numbers), dates (3/20/2012 should be grater as 4/15/2010) and so on. If you just convert HTML table to some grid you will have problems with correct filtering or sorting. Even if you use pure local JavaScript data to display in grid it would be important to have datasource which has some kind of type information and then to create the grid based in the data. In the case you can gives date as JavaScript Date or as ISO 8601 string "2012-03-20" and in the grid display the data corresponds the specified formatter as 3/20/2012 or 20-Mar-2012.
Whether you implement filtering, sorting and paging on the server side or on the client side is not really important for the user who open the page. It's important only that all works quickly enough. The exact choose of the grid plugin, the filtering (with filter toolbar or external controls) and styling of the grid depend on your taste and the project requirements.
I was wondering if there were any nice widgets in wxwidgets, with search ability. I mean searching for data in large tables like, data in wxgrid.
Thanks in advance
It would be slow and inefficient in several ways to store all of a large dataset in wxGrid, and then to search through wxGrid.
It would be better to keep the dataset in a database and use the database engine to search through it. wxGrid need only store the data that is visible in the GUI.
Here is some high level pseudo code of how this works.
Load data into store. The store should probably be a database, but it might be a vector or any STL container. Even a text file could be made to work!
Set current viewable row to a sensible value. I am assuming your data is arranged in rows
Load rows including and around current into wxGrid.
User enters search term
Send search request to data store, which returns row containing target
Set current row to row containing target
Load rows including and around current into wxGrid.
Let's say I have ten rows on a data grid and I have changed data of three rows.
I am trying to save data by Linq for those three rows, but I am not sure how it is possible to save them.
I can do it by looping whole rows by checking each row for any change.
Is there any smarter way to save multiple data rather than looping by code, such as For Next.
As long as the Data Context is kept alive while the changes are made in the grid, you can save all of the changes by calling SubmitChanges() using the Unit of Work pattern. This works fine in stateful (Winform/WPF) implementations. In web applications, the typical UI models only allow for editing a single row per page submission. In that case, the challenge becomes how to allow editing multiple records in a single page request. If you can do that, then you can batch up your updates and only call SubmitChanges once per page request.
I am contemplating between using a grid plugin for Jquery vs manually adding rows to the html table (using Jquery). All I need to do is display the data in a table, have one field editable, then save the data to the database. i have a limited deadline and don't have the time to learn a new plugin (such as jqgrid which is quite complex).
I would normally display around 200 rows to the user..what I am wondering about is in terms of speed would it be really poor performance to add row to the html table 200 times? Would a plugin really speed up the performance (hence making it almost necessary for me to use one)? I know JavaScript can be slow when not optimized which is why I would like to know.
Any thoughts/advice?
There is nothing that a plugin does that would necessarily be faster than what you can write yourself.
That being said, the fastest way to do this for you would be to create a string of the HTML table rows (append each row to the string) and then to set the innerHTML to the string. Don't build the DOM nodes directly & append, that is the worst performance.
Source: http://www.quirksmode.org/dom/innerhtml.html
Look at examples from the answer. In the example will be added 1000 lines to the grid and all work quickly.
It would be much better if you posted the prototype of your grid which you currently use. Moreover jqGrid support many scenarios for local and remote data and many ways of editing local and remote data. Do you choosed already one way or at least direction in which you want to go? If you plan to access remote backend server having database, more information is required. At least one need to know which technology you use on the server (ASP.NET MVC, WFC, ASMX web services, PHP, Java Servlet and so on).