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

[Solved] RadGrid - Go through all DataItems and find RadComboBox CLIENTSIDE

5 Answers 345 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Laz
Top achievements
Rank 1
Laz asked on 16 Jun 2009, 08:23 AM

Hi to all,

in my szenario i use in a Grid a RadToolBar with a RadComboBox to filter (clientside) dataitems in the Grid. This works well!

Now i would like to go through to all DataItems which are Visible = true (x.get_visible()) and find the RadComboBoxes named "rcbCategory" to change the value and the text.

How can i get an instance to change value and the text.

Here is the JavaScript, where i would like to find the RadComboBox in the Grid:

        function DecisionExecute() {  
 
           // GetRegisteredServerElement('ddlCategory');  
            var DataItems = $find("<%=rdgWI.ClientID %>").get_masterTableView().get_dataItems();  
            for (i = 0; i < DataItems.length; i++) {  
                //HERE I NEED TO FIND THE RADCOMBOBOX                 
            }  
        }  
 

Here is the ASCX:
<table cellpadding="0" cellspacing="0" border="0" width="100%">  
    <tr> 
        <td> 
            <telerik:RadToolBar ID="rdtbWl" runat="server" Style="display: block; float: none" Visible="false" 
                Width="100%">  
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                <Items> 
                    <telerik:RadToolBarButton Value="rtbWTypes" Text="rtbWTypes">  
                        <ItemTemplate> 
                            <telerik:RadComboBox ID="rcbWTypes"   
                                                    runat="server"   
                                                    CssClass="DefaultText" 
                                                    OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" 
                                                    DataTextField="Stext" 
                                                    DataValueField="Stext" 
                                                    HighlightTemplatedItems="True">  
                                <CollapseAnimation Duration="200" Type="OutQuint" /> 
                            </telerik:RadComboBox> 
                        </ItemTemplate> 
                    </telerik:RadToolBarButton> 
 
                    <telerik:RadToolBarButton Value="rtbColumnDecision" Text="rtbColumnDecision">  
                        <ItemTemplate> 
                            <telerik:RadComboBox ID="rcbColumnDecision"   
                                                    runat="server"   
                                                    CssClass="DefaultText"   
                                                    OnClientItemsRequested="ItemsLoaded" 
                                                    OnItemsRequested="rcbColumnDecision_ItemsRequested">  
                                <CollapseAnimation Duration="200" Type="OutQuint" /> 
                            </telerik:RadComboBox> 
                        </ItemTemplate>      
                    </telerik:RadToolBarButton> 
                                         
                    <telerik:RadToolBarButton Text="Execute" Value="Execute" runat="server">  
                        <ItemTemplate> 
                            <asp:Button ID="btnColumnDecisionExecute" runat="server" Text="Execute" OnClientClick="ColumnDecisionExecute()" /> 
                        </ItemTemplate> 
                    </telerik:RadToolBarButton> 
                </Items> 
            </telerik:RadToolBar> 
        </td> 
    </tr> 
    <tr> 
        <td width="100%">  
            <telerik:RadGrid ID="rdgWI" 
                             runat="server"   
                             AutoGenerateColumns="False" 
                             GridLines="None"   
                             AllowPaging="False" 
                             onneeddatasource="rdgWI_NeedDataSource"   
                             PageSize="8" 
                             AllowSorting="true">  
                <HeaderContextMenu> 
                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                </HeaderContextMenu> 
 
                <ClientSettings> 
                    <Scrolling AllowScroll="True" UseStaticHeaders="true" /> 
                    <ClientEvents OnGridCreated="GetGridObject"></ClientEvents> 
                </ClientSettings> 
 
                <MasterTableView ClientDataKeyNames="RhText" ShowHeadersWhenNoRecords="true" AllowSorting="True" ShowHeader="true" runat="server">  
                     
                    <RowIndicatorColumn> 
                        <HeaderStyle Width="20px"></HeaderStyle> 
                    </RowIndicatorColumn> 
                    <ExpandCollapseColumn> 
                        <HeaderStyle Width="20px"></HeaderStyle> 
                    </ExpandCollapseColumn> 
                    <Columns> 
                        <telerik:GridBoundColumn  DataField="WiId" UniqueName="WiId" Visible="false">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridTemplateColumn HeaderText="Category" SortExpression="" UniqueName="Category" Visible="false">  
                <ItemTemplate> 
                        <telerik:RadComboBox ID="rcbCategory" DataSource='<%# GetDdlCategoryDataSource(Eval("RhTask")) %>' DataValueField="Description" DataTextField="Stext" runat="server"></telerik:RadComboBox>     
                </ItemTemplate>                                                                 
                        </telerik:GridTemplateColumn> 
                    </Columns> 
                </MasterTableView> 
                <FilterMenu> 
                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                </FilterMenu> 
            </telerik:RadGrid> 
        </td> 
    </tr> 
</table> 

Thanks in advance

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Jun 2009, 10:47 AM
Hi Laz,

Go through the code library which describes how to access the server controls in a grid template on the client. I hope this would be of help in accomplishing the required functionality.
Accessing server controls in a grid template on the client

Shinu
0
Laz
Top achievements
Rank 1
answered on 16 Jun 2009, 11:40 AM
Hi,

thank you for the hint!
But i follow the approach only to go through the DataItems which i have set to Visible.
If i look at the code library then i have always go through all DataItems which i have registered in a Array.

It is not possible to get all controls of a DataIitem at get the current ClientID of the RadComboBox?
That is all i need?
0
Accepted
Daniel
Telerik team
answered on 18 Jun 2009, 08:16 PM
Hello Laz,

I suggest you modify your client-side code a bit:
    function DecisionExecute()  
    {  
        var DataItems = $find("<%= RadGrid1.ClientID %>").get_masterTableView().get_dataItems();  
        for (i = 0; i < DataItems.length; i++)  
        {  
            var combo = $telerik.findControl(DataItems[i].get_element(), "rcbCategory");  
            alert(combo.get_id());  
        }  
    } 

Hope this helps.

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Laz
Top achievements
Rank 1
answered on 19 Jun 2009, 08:40 AM
Hi Daniel,

thank you for your support!

I have a further question, i hope you can help me?

In my RadGrid i have a Checkbox in a GridTemplateColumn
<telerik:GridTemplateColumn Display="false">  
  <ItemTemplate> 
     <asp:CheckBox ID="chkbSelected" runat="server" /> 
  </ItemTemplate> 
</telerik:GridTemplateColumn> 
 

If i try to find this Control it fails
My Statement:

  • var checkbox    = $telerik.findControl(DataItems[i].get_element(), "chkbSelected");

is wrong i think

function ColumnDecisionExecute() {  
    var DataItems = $find("<%=rdgWorklistInbox.ClientID %>").get_masterTableView().get_dataItems();  
 
    for (i = 0; i < DataItems.length; i++) {  
     if (DataItems[i].get_visible())   
      {  
        var combo       = $telerik.findControl(DataItems[i].get_element(), "rcbCategory");  
        var checkbox    = $telerik.findControl(DataItems[i].get_element(), "chkbSelected");  
     }  
    }  
}  
 
0
Accepted
Daniel
Telerik team
answered on 24 Jun 2009, 08:53 AM
Hello Laz,

Please note that the standard ASP.NET controls (this includes the CheckBox) don't have a client object. In this case I recommend you use findElement method instead.
var checkbox = $telerik.findElement(DataItems[i].get_element(), "chkbSelected");   

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Laz
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Laz
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or