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

[Solved] RadGrid - Clientside Filter by RadComboBox

2 Answers 390 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Laz
Top achievements
Rank 1
Laz asked on 11 Jun 2009, 09:44 AM

Hi,

my problem is that i want to filter clientside.

Within tabs i use the RadGrid - Control.

To Filter clientside i define in the RadGrid

  • a <ClientSettings> Section and
  • a the MasterTAbleView - Attribute "DataKeyNames"

But when i go through the Records the Statement:
(Triggert by RadComboBox OnClientSelectedIndexChanged)

DataItems[i].getDataKeyValue("DataKeyName")

is always null.

Here the Code snippets

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
 
    <script type="text/javascript">  
 
        var RadGrid1;  
 
        function GetGridObject(sender, eventArgs) {  
             RadGrid1 = sender;  
        }  
 
        function OnClientSelectedIndexChanged(sender, eventArgs) {  
 
            var item = eventArgs.get_item();  
            if (item.get_value() == "1") {  
                 ShowRow();  
            }  
            else {  
                ShowRow();  
                HideRow(item.get_text());  
            }  
             
 
           }  
 
          function HideRow(absencetype) {  
            var DataItems = $find("<%=rdgInbox.ClientID %>").get_masterTableView().get_dataItems();  
                     
              
            for (i = 0; i < DataItems.length; i++) {  
                
                    if (DataItems[i].getDataKeyValue("WText") == absencetype) {  
                        RadGrid1.get_masterTableView().hideItem(i);  
                         
                    }                                  
            }  
        }  
 
        function ShowRow() {  
 
            var DataItems = $find("<%=rdgInbox.ClientID %>").get_masterTableView().get_dataItems();  
            for (i = 0; i < DataItems.length; i++) {  
                RadGrid1.get_masterTableView().showItem(i);  
            }  
        }  
 
    </script> 
 
</telerik:RadCodeBlock> 
 
      
<table cellpadding="0" cellspacing="0" width="100%">  
    <tr> 
        <td> 
            <telerik:RadToolBar ID="rdtbWorklist" runat="server" Style="display: block; float: none" Visible="false" 
                Width="100%">  
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                <Items> 
                    <telerik:RadToolBarButton Value="rtbWorklistTypes">  
                        <ItemTemplate> 
                            <telerik:RadComboBox ID="rcbWorklistTypes" runat="server" CssClass="DefaultText"  OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" 
                                DataTextField="Shorttext" 
                                DataValueField="Shorttext" HighlightTemplatedItems="True">  
                                <CollapseAnimation Duration="200" Type="OutQuint" /> 
                            </telerik:RadComboBox> 
                        </ItemTemplate> 
                    </telerik:RadToolBarButton> 
                </Items> 
            </telerik:RadToolBar> 
        </td> 
    </tr> 
    <tr> 
        <td width="100%">  
            <telerik:RadGrid ID="rdgInbox" 
                             runat="server"   
                             AutoGenerateColumns="False" 
                             GridLines="None"   
                             AllowPaging="True" 
                             onneeddatasource="rdgtInbox_NeedDataSource"   
                             PageSize="8" 
                             AllowSorting="true">  
                <HeaderContextMenu> 
                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                </HeaderContextMenu> 
 
                <MasterTableView DataKeyNames="WText" ShowHeadersWhenNoRecords="true" AllowSorting="True" runat="server">  
                     
                    <RowIndicatorColumn> 
                        <HeaderStyle Width="20px"></HeaderStyle> 
                    </RowIndicatorColumn> 
                    <ExpandCollapseColumn> 
                        <HeaderStyle Width="20px"></HeaderStyle> 
                    </ExpandCollapseColumn> 
                    <Columns> 
                        <telerik:GridBoundColumn DataField="WId" UniqueName="WiId" Visible="false">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridTemplateColumn HeaderText="Category" SortExpression="WText" UniqueName="WText" DataField="WText">  
                            <ItemTemplate> 
                                <asp:Label ID="lblTaskCategory" runat="server" Text='<%# GetTaskCategory(Eval("WTask")) %>' ToolTip="" /> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
                        <telerik:GridTemplateColumn HeaderText="Decision" SortExpression="" UniqueName="Decision">  
                            <ItemTemplate> 
                                <asp:DropDownList ID="ddlDecision" DataSource='<%# GetDataSource(Eval("WTask")) %>' DataValueField="Description" DataTextField="Shorttext" runat="server"></asp:DropDownList> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
                        <telerik:GridTemplateColumn HeaderText="Description" DataField="WiText"   
                            UniqueName="WiText">  
                            <ItemTemplate> 
                                <asp:LinkButton ID="lbWiText" runat="server"   
                                    CommandArgument='<%# Eval("WiId") %>'   
                                    CommandName="ShowDetails"   
                                    Text='<%# Eval("WiText") %>' OnCommand="btnShowDetails">  
                                </asp:LinkButton> 
                        </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
                        <telerik:GridDateTimeColumn HeaderText="Created Date" DataField="WiCreatedDate" AllowSorting="true" 
                            UniqueName="WiCreatedDate" DataFormatString="{0:d}">  
                            <ItemStyle Width="100px" /> 
                        </telerik:GridDateTimeColumn> 
                        <telerik:GridBoundColumn HeaderText="Status" DataField="Statustext" AllowSorting="true" 
                            UniqueName="Statustext">  
                            <ItemStyle Width="100px" /> 
                        </telerik:GridBoundColumn> 
                    </Columns> 
                </MasterTableView> 
                <ClientSettings> 
                    <Scrolling AllowScroll="True" UseStaticHeaders="true" /> 
                    <ClientEvents OnGridCreated="GetGridObject"></ClientEvents> 
                </ClientSettings> 
                <FilterMenu> 
                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                </FilterMenu> 
            </telerik:RadGrid> 
        </td> 
    </tr> 
</table> 

In the function HideRow is my problem located. DataItems[i].getDataKeyValue("WText")  is always NULL

Thanks for help

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 12 Jun 2009, 10:14 AM
Hello Laz,

You would have to set the ClientDataKeyNames property of the MasterTableView as 'WText', to access the datakeyvalue on the client.
aspx:
<telerik:RadGrid ID="rdgInbox" runat="server" AutoGenerateColumns="False" 
  GridLines="None"  AllowPaging="True" onneeddatasource="rdgtInbox_NeedDataSource"   
 PageSize="8"  AllowSorting="true">    
                <MasterTableView ClientDataKeyNames="WText"  
ShowHeadersWhenNoRecords="true" AllowSorting="True" runat="server"

Hope this helps..
-Princy.
0
Laz
Top achievements
Rank 1
answered on 12 Jun 2009, 11:24 AM
That work great thank´s
Tags
Grid
Asked by
Laz
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Laz
Top achievements
Rank 1
Share this question
or