Hi all,
To save a round trip to the database, I would like to be able to filter radgrid items client side for speed purposes. I have a grid that will contain anywhere from 500-2500 items in columns representing Departments in a database. The grid has client paging on as well as drag and drop columns. I would prefer to keep the paging at least.
<telerik:RadCodeBlock runat="server" ID="radCodeBlock"> <script type="text/javascript"> function CustFilter() { var chk = document.getElementById('<%=CheckBox1.ClientID %>'); if (chk.checked == true) { var radG = $find("<%=RadGrid1.ClientID %>"); var DataItems = radG.get_masterTableView().get_dataItems(); var masterTableView = radG.get_masterTableView(); for (i = 0; i < DataItems.length; i++) { var row = DataItems[i].get_element(); //var row = masterTableView.get_dataItems()[i]; var checkBox = row.children[5].children[0]; //var checkBox = row.get_cell("Approved") if (!checkBox.checked) { radG.get_masterTableView().hideItem(i); } else { radG.get_masterTableView().showItem(i); } } } else { alert("unchecked"); } } </script> </telerik:RadCodeBlock> <telerik:RadGrid ID="RadGrid1" runat="server" PageSize="50" Height="600px" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" DataSourceID="SqlDsGetRetDepts" GridLines="None" ShowGroupPanel="True" Skin="Windows7" AutoGenerateColumns="false" EnableLinqExpressions="false"> <ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True" ReorderColumnsOnClient="True"> <ClientEvents OnRowContextMenu="RowContextMenu" /> <Scrolling AllowScroll="True" UseStaticHeaders="True" /> <Selecting AllowRowSelect="true" /> </ClientSettings> <MasterTableView DataSourceID="SqlDsGetRetDepts" ClientDataKeyNames="DeptID, CustomerID" DataKeyNames="DeptID"> <Columns> <telerik:GridBoundColumn DataField="DeptID" FilterControlWidth="50px" ItemStyle-Width="100px" HeaderText="DeptID" SortExpression="DeptID" UniqueName="DeptID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustID" ItemStyle-Width="100px" AutoPostBackOnFilter="false" SortExpression="CustID" UniqueName="CustomerID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="DeptName" FilterControlWidth="100px" ItemStyle-Width="100px" HeaderText="Name" SortExpression="Name" UniqueName="DeptName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="DeptPhone" FilterControlWidth="50px" ItemStyle-Width="100px" HeaderText="DeptPhone" SortExpression="DeptPhone" UniqueName="DeptPhone"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="BillDeptID" HeaderText="Bill DeptID" SortExpression="Bill DeptID" UniqueName="BillDeptID"> </telerik:GridBoundColumn> <telerik:GridCheckBoxColumn DataField="Approved" HeaderText="Approved" SortExpression="Approved" UniqueName="Approved"> </telerik:GridCheckBoxColumn> </Columns> </MasterTableView> </telerik:RadGrid>One of those columns is a boolean field called "Approved" in a gridcheckboxcolumn . I woudl like the user to be able to check a checkbox and filter out all those that are not "Approved". I cant quite glean from other posts how to do this, my client-side code is not quite there. I am missing something, as I am hiding all the data on the page, and when I page the data is all there. Any help would be appreciated! Thanks in advance,
Nimesh Jagota