This is a migrated thread and some comments may be shown as answers.

Initially loading data locally with remote data source

2 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 11 Nov 2013, 12:10 PM
I have Grid View which I'm using with a remote data source but initially populating with local data. Basically the same requirement as the following 
http://www.kendoui.com/forums/kendo-ui-web/grid/initial-load-locally-with-remote-datasource.aspx except that I'm using .NET MVC extensions.

Its essentially working as a normal remotely loaded grid view but I'm also passing data with a view model on the initial page load.

This seems to work fine (at least with a smallish data set) however I can't find any other examples of anyone doing this which makes me wonder if I'm being stupid and there is a reason I shouldn't do this? Is the fact the I'm using 2 data set likely to cause issues that I've not yet discovered? Would the fact I'm not passing my data DataSourceResult in Index() mean I bring more data to the server than I need to? The data set for this isn't big, but it's being pulled together from various sources so it is quite slow, so speed is a big consideration for me.

My Grid view is as follows
@model IEnumerable<MVCCOD.ViewModels.ProviderDisputeViewModel>
 
@(Html.Kendo().Grid(Model).Name("Disputes").Columns(c => {
    c.Bound(p => p.ID);
    c.Bound(p => p.BillingPrvName);
 /* etc */
  }
    ).
    DataSource(d => d
        .Ajax()
        .Read(r => r.Action("JsonRead", "ProviderDispute")).PageSize(50)
    ).
Pageable().
Sortable())
Controller is below where the view is loaded via ActionIndex
    public class ProviderDisputeController : Controller
    {
        public ActionResult Index()
        {
               return View(GetDisputes());
        }
 
        public ActionResult JsonRead([DataSourceRequest] DataSourceRequest request)
        {
            return Json(GetDisputes().ToDataSourceResult(request));
        }
 
        private List<ProviderDisputeViewModel> GetDisputes()
        {
/* etc */
}
}

2 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 13 Nov 2013, 08:06 AM
Hi Michael,

 
Basically the mode that you choose is working as expected, however you should consider the following:

  • When the initial data is loaded from ViewModel only server templates (such as Template method) will be used, however for each request after the initial one the client templates will be used (such as ClientTemplate method). That way you should maintain both server and client templates if you choose to stay with current configuration. When only Ajax binding is used you should maintain only the client templates. 
  • When the data for the Grid takes longer to load, with current configuration the user wouldn't be able to see the page at all until the data is loaded. In opposite when only Ajax binding is used the page will be loaded instantly and the Grid will show it's loading icon until the data is loaded (more user-friendly). 

Considering the above points I would suggest to use only Ajax binding to load the Grid with data. Also if you choose to stay with current configuration you should return only the data for the first page to the View. 
Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Michael
Top achievements
Rank 1
answered on 14 Nov 2013, 09:45 AM
Thanks very much for the response Vladamir, very helpful.

The reason I was trying to set the page up this way was actually to try to avoid the more user-friendly method. Strangely we've had complaints from users about the load speed when we use the Ajax method but didn't pre-Kendo when the whole page loaded slowly - Its not that the overall page actually loads noticeably more slowly, I think its just because the users are used to one long wait rather than 2 shorter ones. I think I will try to stick with the conventional 100% Ajax approach for now and hope the user get used to it.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Michael
Top achievements
Rank 1
Share this question
or