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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dont want grid to refresh the datasource upon paging request.

Thread ID:

Created:

Updated:

Platform:

Replies:

99280 May 10,2011 05:23 PM UTC Feb 25,2013 09:28 AM UTC ASP.NET MVC (Classic) 11
loading
Tags: Grid
Jason Beal
Asked On May 10, 2011 05:23 PM UTC

I want to know if its possible to do the following.

I want to have the grid initially populated from a datasource that uses a LINQ-to-SQL query. Then upon any paging, filtering, grouping, etc calls back to the controller, I don't want to refresh the datasource from the database. I want it to keep using the snapshot of data it initially retrieved. Is this possible?
I looked at custom binding, but it seems any paging requests etc, it refreshes the datasource. Is there a way to serialize the grids data into a JSON string and have it accompany the paging controller methods somehow?

I'm trying to provide users with a snapshot, allow them to edit values using a custom form, and then publish the changes at a later time, using a disconnected model.


Eswari S [Syncfusion]
Replied On May 16, 2011 06:29 AM UTC

Hi Jason,

Thank you for your interest with Syncfusion products.

Query #1:Want to know if it’s possible to do the following

we can use the initially retrieved data in post actions by using static keyword.

We have prepared the basic grid sample for your reference, Please find the sample from the following link.

Flat Grid Sample-1043334995.zip

Note: To run the samples in MVC3, change the configuration manager as Debug_MVC3/Release_MVC3.

To know more about the steps to switch between (Mvc2 to Mvc3) , please refer to the sample document here :

How to Switch between MVC2 to MVC3

Please refer the following code snippets:

static IEnumerable data; // static data
public ActionResult FlatGrid( )
{
data = new NorthwindDataContext().Orders.ToList();
return View(data);
}

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult FlatGrid(PagingParams args)
{
return data.GridActions();
}

Query #2:Publish the changes at a later time, using a disconnected model.

We have analyzed your query and we are unable to understand the requirement. If you want to bind the initial data to the post actions, then we can’t get the updated data's into the grid. Could you please provide some scenarios, so that we would be able to provide you the better solution quickly.

Please get in touch with us if you would require any further assistance.

Regards,
Eswari.S




Li
Replied On May 10, 2012 02:46 PM UTC

Realistically, this design is not good. You can't imagine a stateless ASP.Net application with a static data source.
 
In a bigger picture, Syncfusion team need to found a more generic way that posts back to view model. This issue has been bother us a lot!

Bala Murugan A.S [Syncfusion]
Replied On May 18, 2012 04:44 AM UTC

Hi Li,

Thanks for your update.

Could you please provide more information regarding your issue(generic way that posts back to view model) so that we could able to sort out the cause of this issue and provide you a better solutions quickly?

The information provided would be a great help for us to resolve your issue.

Please let us know if you have any concerns.

Regards,
Bala Murugan A.S


Li
Replied On May 24, 2012 01:13 PM UTC

Let me put it this way:
 
In all your sample codes, the datasource is pretty much 'static', meaning that the data posting to client side is the same. However, in a real application, this is very unlikely the case. Every time there is a postback to server, we need to post the model as well. Syncfusion Grid is a new stuff for me, and I don't see a generic way to do that. It takes me 40+ hours to figure out a solution like this
Still, I think it is troublesome to ask a developer to do. Why cannot Grid post back the model?
 
Thanks,
Li
 

Bala Murugan A.S [Syncfusion]
Replied On May 29, 2012 04:59 AM UTC

Hi Li,

Thanks for the update.

We have an option to bind grid with dynamic data source and with the help of this we can able to bind different data source to the grid. The grid takes the same data source if you doing paging, sorting, etc.,

Please refer the below documentation link and online sample link to know more about the Dynamic data binding.

Documentation link:

http://help.syncfusion.com/UG/User%20Interface/ASP.NET%20MVC/Grid/Documents/databinding.htm

Online Sample link(Dynamic data binding):

http://mvc.syncfusion.com/sfmvcsamplebrowser/10.2.0.56/Grid_MVC/Samples/4.0/Razor/DataBinding/DynamicDataBinding

Could you please let me know what is your exact requirement on posting model to the grid on every post back and provide more information on postback model to the grid so that we could able to sort out the problem which you are facing and provide you a better solutions quickly?

Please let us know if you have any concerns.

Regards,

Bala Murugan A.S


Li
Replied On May 29, 2012 02:43 PM UTC

Hi,

I have already read the sample and my solution is like that. However, supposed we have a much more complex form. The datasource is retrieved using these inputs in the code behind. Here is the scenario:

When I turn to the second page or I do inline editing, how can I postback those inputs? "QueryParam" seems to work, but in our application, the data model is so complicated, I would like to postback a view model rather than a long list of query parameters.

I hope you understand my question now.

Thanks,

Li
   


Bala Murugan A.S [Syncfusion]
Replied On May 30, 2012 06:30 AM UTC

Hi Li,

Thanks for your update.

We suggest you to post json data to controller in OnActionBegin events(args.data["Details"]) and Deserialize the json data in controller for you requirement. Please refer the below code snippet.

[Site.Master]
<script type="text/javascript">

        function OnActionBegin(sender, args) {

            var dobj = [{ id: 1, name: 'ABCD', email: 'abcd@one.com' },
                        { id: 2, name: 'EFGH', email: 'efgh@one.com' },
                        { id: 3, name: 'IJKL', email: 'ijkl@one.com' },
                        { id: 4, name: 'MNOP', email: 'mnop@one.com'}];

            var jlst = JSON.stringify(dobj);
            
            args.data["Details"] = jlst;
        }


    </script>

[Index.aspx]
 <% =Html.Syncfusion().Grid<object>("ProductGrid")                        
                        .Datasource((IEnumerable)ViewData["GridModel"])                    
                        .EnablePaging()
                        .EnableSorting()
                        .AutoFormat(Skins.Sandune).EnableGrouping().ClientSideEvents(events => { events.OnActionBegin("OnActionBegin"); })
  %>

[HomeController.cs]

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Index(PagingParams args, string Details)
        {
          
            IList<Person> persons = new JavaScriptSerializer()
                  .Deserialize<IList<Person>>(Details);

            //do other stuff
            var data = new NorthwindDataContext().Products.Take(50).ToList();
            ViewData["GridModel"] = data;
            return data.GridActions<Product>();
        }

We have prepared a simple sample to demonstrate this and the same can be downloaded from the below link.

Sample link:http://www.syncfusion.com/downloads/Support/DirectTrac/94907/GridPartial-1944291038.zip


In the above sample we have passed some sample json data in OnActionBegin event to Controller(Index - post Action) and with the help of another argument in that method we have got that json data as string format. Finally we have deserialized that json data. In this way you can pass complex data to controller while moving to another page.

Please try the above sample and let us know if you need further assistance.

Regards,
Bala Murugan A.S




Li
Replied On May 30, 2012 03:00 PM UTC

Pretty good. I tried that one too, and it worked. I think you should include this sample into documentation, and that is a good example.


Bala Murugan A.S [Syncfusion]
Replied On May 31, 2012 04:16 AM UTC

Hi Li,

Thanks for your update.

We will consider your request.

Please let us know if need further assistance.

Regards,
Bala Murugan A.S

Chandra Sadhangiri
Replied On February 20, 2013 05:24 PM UTC

Hi,
I have a similar problem and I think this solution works for me too.
Can you please upload the sample developed that works with VS2012 MVC4 and Syncfusion 10.4.0.71 

http://www.syncfusion.com/downloads/Support/DirectTrac/94907/GridPartial-1944291038.zip

Thanks,
Chandra

Rakesh D [Syncfusion]
Replied On February 25, 2013 09:28 AM UTC

 

Hi Chandra,

 

Thank you for your interest in Syncfusion products.

 

As per your requirement we have modified the above sample which works in MVC 4 (VS2012) in 10.4.0.71 version and it is attached below. Please refer to it.

 

 

Please let us know if you have any concerns.

 

Regards,

Rakesh D                                                                                                                                          

                                                                                                                   



Grid_JsonData_af172575.zip

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

;