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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to dynamically change grid datasource without hitting controller every time

Thread ID:

Created:

Updated:

Platform:

Replies:

111185 Sep 11,2013 05:56 PM UTC Sep 19,2013 12:48 PM UTC ASP.NET MVC (Classic) 4
loading
Tags: Grid
Andrew
Asked On September 11, 2013 05:56 PM UTC

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.

Eswari S [Syncfusion]
Replied On 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


Andrew
Replied On 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>();

}


Andrew
Replied On 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?

Eswari S [Syncfusion]
Replied On 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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;