We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to dynamically change grid datasource without hitting controller every time

I'm trying to figure out a way to change the datasource and make dynamic UI updates without hitting the server when actions happen. For example, you have an example on your site of a dynamic binding for the grid. The problem with that is that it hits the controller every single time you select a different datasource. Lets just say I've already loaded the data from the server using JQuery and I have it stored in some kind of Javascript array or JSON. I just want to change the datasource of the grid to one of these sources that I've already loaded so that I can quickly make UI updates and quickly change the data in the grid without calling the controller every single time.

4 Replies

ES Eswari S Syncfusion Team September 12, 2013 12:59 PM UTC

Hi Andrew,

 

Thank you for using Syncfusion products.

 

Your requirement can be achieved in JSON mode using set_dataSource() function . Please refer to the following code snippets:

 

$("#updateDB").live("click", function () {  // click update data function to Update data source

        var data =

        [{ "UniversityCode": 10001, "Title": "Distributed Component Architecture", "Duration": 90, "CourseFees": 2000, "CGPA": 1 },

        { "UniversityCode": 10002, "Title": "Data Structures", "Duration": 60, "CourseFees": 1000, "CGPA": 2 },

        { "UniversityCode": 10003, "Title": "Neural Networks", "Duration": 75, "CourseFees": 1750, "CGPA": 3}];

 

        $find("Grid1").jsonModeMgr.set_dataSource(data); // “Grid1” is grid ID

    });

 

For your convenience , we have prepared the sample and the same can be downloaded from the following link    

 

Sample.zip

 

Please try this and let us know if you have any queries.

 

Regards,

Eswari S



AN Andrew September 17, 2013 05:47 PM UTC

When I use JSON mode, do I have to use this method? This is extremely inefficient. It seems to me that paging should be a client side action. I don't want to have to hit my datasource over and over again everytime someone wants to go to another page.
 

[

AcceptVerbs(HttpVerbs.Post)]

public ActionResult ServerPaging(PagingParams args)

{

            IEnumerable data =new StudentDataContext().Student.ToList();

return data.GridJSONActions<Student>();

}



AN Andrew September 17, 2013 05:50 PM UTC

Also, if that is how I page the grid, then how do I page once I've changed the datasource client side?


ES Eswari S Syncfusion Team September 19, 2013 12:48 PM UTC

Hi Andrew,

 

Thanks for your update.

 

Currently we do not support for 'Client Side Data Processing' in the Essential Grid MVC. We can achieve your requirement using JavaScript control. We suggest you to use Essential JavaScript control. Please check with the following online sample link for JavaScript controls:

 

http://js.syncfusion.com/demos/beta/#!/flat/grid/Paging

 

Please let us know if you would require any further assistance.

 

Regards,

Eswari S


Loader.
Live Chat Icon For mobile
Up arrow icon