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

[Solved] Issues with client side binding sorting and paging

1 Answer 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tim
Top achievements
Rank 1
Tim asked on 06 Jul 2010, 08:51 PM
I am binding a grid on the client side using json and jquery which is in turn breaking the sorting and paging functionality of the grid. On the initial page load I have no records to display and do not bind the grid. I have several user controls on the page, mostly multi-select listboxes and a search button. When the search button is clicked I use jquery to get the selected values from the multi-selects and pass these values to a json method which queries the database using the selected params and sends back an iqueryable. On the client side I get my grid and bind to the iqueryable as such:

var grid = $("#DocumentSearch").data('tGrid');
grid.databind(data.GridData);
grid.total = data.GridData.length;
grid.updatePager;

This works great as far as binding the grid initially, however when I enable sorting on the columns it does a get - which returns an empty grid. I have the same issue if paging is enabled. I will include some of the code below, any help would be greatly appreciated.

the grid code from the aspx:
<% 
              
        Html.Telerik().Grid<ePs.Frm.Core.Model.Core.SafetyDocumentsUpload>() 
            .Name("DocumentSearch"
            .Columns(columns => 
            { 
                columns.Bound(c => c.Id).Title("").Format("<input class='selectedRow' type='checkbox' />").Encoded(false).Width(100).HtmlAttributes(new { style = "text-align:center" }); 
                columns.Bound(o => o.SafetyDocumentsName).Width(100).Title("Document Name"); 
                columns.Bound(o => o.TherapeuticAreaName).Width(100).Title("Therapeutic Area"); 
                columns.Bound(o => o.CompoundName).Width(100).Title("Compound"); 
                columns.Bound(o => o.ProtocolName).Width(100).Title("Protocol Number"); 
                columns.Bound(o => o.SafetyDocumentType).Width(100).Title("Document Type"); 
                columns.Bound(o => o.UploadDate).Width(100).Title("Upload Date"); 
 
            }) 
            .Pageable(paging => paging.PageSize(4)) 
            .Sortable() 
            .Render(); 
      %> 

js to bind the grid:
if (data.BindGrid) 
                { 
                    selectedRows = []; 
                    $(".selectedRow:checked").each(function () 
                    { 
                        if (this.value != "on"
                            selectedRows.push(this.value); 
                    }); 
                    var grid = $("#DocumentSearch").data('tGrid'); 
                    grid.dataBind(data.GridData); 
                    grid.total = data.GridData.length; 
                    grid.updatePager(); 
 
                    for (var i = 0; i < selectedRows.length; i++) 
                    { 
                        var checkbox = $("input.selectedRow[value=" + selectedRows[i] + "]"); 
                        checkbox.attr('checked''checked'); 
                    } 
 
                    gridDiv[0].style.display = "block"
                } 

1 Answer, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 06 Jul 2010, 09:18 PM
Is there an api somewhere of all the clientside functions available? - it took lots of searching just to find the dataBind and updatePager functions.
Tags
Grid
Asked by
Tim
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Share this question
or