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

2013 Grid - Programmatic Binding

8 Answers 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nik
Top achievements
Rank 1
Nik asked on 07 Dec 2013, 12:08 PM
I have implemented client side binding just as described under http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/programmatic/defaultcs.aspx.
Only difference is that I get data from a WCF Service instead of Page methods. Paging and Filters are working fine. 
But having problems implementing Virtualization as described under http://demos.telerik.com/aspnet-ajax/grid/examples/performance/virtualization/defaultcs.aspx.
I don't want to use NeedDataSource event as I only want to communicate with Web service.
Both Paging and Scrolling fire ONCommand event which run into error.
Can anyone pls. help!


 


8 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 11 Dec 2013, 03:54 PM
Hi Nik,

A possible solution is to check whether the fired command is Paging or Scrolling and if it is one of them to stop executing your logic. You could get the command name from the arguments. Please check out the following code snippet.
<script type="text/javascript">
     function OnCommnad(sender, args)
     {
         if (args.get_commandName() != "Page")
         {
             //your logic comes here
         }
     }
</script>

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Nik
Top achievements
Rank 1
answered on 13 Dec 2013, 08:12 AM
Hi Kostadin,

Thanks for the reply. Both paging and scrolling fire Page command. And as I said there were errors on both these actions.
Meanwhile I got it working with 
 <%--<Virtualization EnableVirtualization="true"  InitiallyCachedItemsCount="2000" ItemsPerView="100" LoadingPanelID="RadAjaxLoadingPanel1" 
                 />--%>
            <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="500px" EnableVirtualScrollPaging="true"   />

I will try again with Virtualization and let you know the exact error description.

Regards
Nik
0
Nik
Top achievements
Rank 1
answered on 30 Apr 2014, 06:42 PM
http://demos.telerik.com/aspnet-ajax/grid/examples/performance/virtualization/defaultcs.aspx

Actully this demo works only with the server side solution. on the server side whole table is loaded only once.
With the client side data binding it simply does not work.
I get the next pagesize rows on command event in javascript.
Does anyone has a client side solution ?
0
Genady Sergeev
Telerik team
answered on 06 May 2014, 12:58 PM
Hello Nikunj,

If you want to use WebService binding instead of PageMethods simply replace the
PageMethods.GetData(currentPageIndex * pageSize, pageSize, sortExpressionsAsSQL, filterExpressions.toList(), updateGrid);

invocation with a call to a web-service (you can use jQuery to do that). You can again load the datatable in the service only once and reuse it with each request.

If substituting PageMethods call with a call to the web-service could you please elaborate a bit more on what piece of your solution is not working so that we can take a look.

Regards,
Genady Sergeev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Nik
Top achievements
Rank 1
answered on 06 May 2014, 05:09 PM
Hello Genady,
Many thanks for the reply.
My Problem is that Vertical scrollbar scrolls too fast and too many pages with each click on the scrollbar arrow.
If I have 50 as pagesize and the visible rows are 10 then depending on the Total rows count, I can only scroll down to not more than 10 rows.
I fetch new rows on each page command from the web service. 
And while scrolling up, there are blank rows then suddenly the pageIndex changes which is not smooth scrolling behaviour.
It would be best if you could send me a demo of virtual scrolling with non-declarative client side binding.

thisInstance.RadGrid_OnCommand = function (sender, args) {
        args.set_cancel(true);
        thisInstance.tableView = sender.get_masterTableView();
        thisInstance.webDataArgs.pageSize = sender.get_masterTableView().get_pageSize();
        var currentIndex = thisInstance.webDataArgs.currentPageIndex;
        thisInstance.webDataArgs.currentPageIndex = sender.get_masterTableView().get_currentPageIndex();
        thisInstance.webDataArgs.sortExpressions =      sender.get_masterTableView().get_sortExpressions().toString();
        var filterExpressions = sender.get_masterTableView().get_filterExpressions().toString();
        if (args.get_commandName() == "Filter") {
            if (thisInstance.webDataArgs.filterExpressions != filterExpressions) {
                thisInstance.webDataArgs.currentPageIndex = 0;
            }
        }
        thisInstance.webDataArgs.filterExpressions = filterExpressions;
        $(thisInstance.loadingPanel).show();
        thisInstance.GetData(thisInstance.serviceURL + "GetData", thisInstance.webDataArgs, thisInstance.updateGrid);
    }
0
Kostadin
Telerik team
answered on 09 May 2014, 12:32 PM
Hi Nikunj,

In order visualization to work properly you have to pass the entire data base  and not only the current page. For your convenience I prepared a small sample and attached it to this thread. Please give it a try and let me know about the result.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Nik
Top achievements
Rank 1
answered on 10 May 2014, 08:14 AM
Hello Kostadin,
Thank you very much.
But we can not bind the whole datatable. We must use a pagesize less than 100.
Below are my settings and the error I have.
RadGrid1.PageSize = 200;
RadGrid1.ClientSettings.Virtualization.EnableVirtualization = true;
RadGrid1.ClientSettings.Virtualization.InitiallyCachedItemsCount = RadGrid1.PageSize * 2;
RadGrid1.ClientSettings.Virtualization.RetrievedItemsPerRequest = RadGrid1.PageSize * 2;
RadGrid1.ClientSettings.Virtualization.ItemsPerView = 100;
RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None;

0
Kostadin
Telerik team
answered on 14 May 2014, 02:15 PM
Hi Nikunj,

I am afraid that the visualization could not be used in scenario where only a part of the datasource is applied at a current moment. In such cases is expected to receive the aforementioned errors.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Nik
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Nik
Top achievements
Rank 1
Genady Sergeev
Telerik team
Share this question
or