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

set enable/disable in client side.

1 Answer 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 20 Nov 2008, 04:27 PM
Hi,

I have a ajax Grid, and some template columns. 
I want to enable/disable other column if I change the combobox value. How can I do that?
How can I get the client_id of another Grid template item control?
I had try to add a literal control in javascript client side,  but the literal control can not updated because of Ajax.
How can I make this? please help. thanks.

Regards,
Paul.

                                    <telerik:GridTemplateColumn UniqueName="AreaSiteTemplateColumn" HeaderText="Area Site">
                                        <ItemTemplate>
                                            <%#DataBinder.Eval(Container.DataItem,"area_site")%>
                                        </ItemTemplate>
                                        <ItemStyle Width="180px" />
                                        <EditItemTemplate>
                                            <telerik:RadComboBox
                                                DataTextField="system_code_name"
                                                DataValueField="system_code_id"  
                                                EnableLoadOnDemand="False"
                                                MarkFirstMatch="false"
                                                ID="RadComboBoxAreaSite"
                                                OnClientSelectedIndexChanged="AreaSiteOnClientSelectedIndexChanged"
                                                runat="server" 
                                                SelectedValue='<%#Bind("area_site_id") %>'>
                                            </telerik:RadComboBox>
                                        </EditItemTemplate>
                                    </telerik:GridTemplateColumn>  

Script:

                function AreaSiteOnClientSelectedIndexChanged(sender, args) {               
                    var carparkId, comboUsageId;                           
                    var carpark, comboUsage;
                   
                    var item = args.get_item();

                        switch (sender.get_id())
                        {               
                            <asp:Literal ID="litFindControl" runat="server" />

                            default :

                            break;                   

                        }
                       
                    carpark = $find(carparkId);
                    comboUsage = $find(comboUsage);                       
                   
                    if (item.get_text() == "Above Ground")   
                    {
                        carpark.set_value("");
                        carpark.disable();
                       
                        comboUsage.enable();
                    }
                    else if (item.get_text() == "Caraprk")
                    {                       
                        carpark.enable();
                       
                        comboUsage.set_value();
                        comboUsage.disable(); 
                    }                    
                }

server side:
    protected void RadGridAboveGround_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {        
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            GridEditManager editMan = editedItem.EditManager;

            RadNumericTextBox txtNoOfCarpark = editedItem.FindControl("txtNoOfCarpark") as RadNumericTextBox;
            RadComboBox comboUsage = editedItem.FindControl("RadComboBoxPropertySector") as RadComboBox;
            RadComboBox comboAreaSite = editedItem.FindControl("RadComboBoxAreaSite") as RadComboBox;

            litFindControl.Text += " case \"" + comboAreaSite.ClientID + "\":" + Environment.NewLine;
            litFindControl.Text += " carparkId = \"" + txtNoOfCarpark.ClientID + "\";" + Environment.NewLine;
            litFindControl.Text += " comboUsageId = \"" + comboUsage.ClientID + "\";" + Environment.NewLine;
            litFindControl.Text += " break;" + Environment.NewLine;
        }
    }

1 Answer, 1 is accepted

Sort by
0
Bodevain Svensson
Top achievements
Rank 1
answered on 24 Nov 2008, 02:10 PM
Paul, I found very useful code library project about how to reference controls in grid templates client-side - check it out:

http://www.telerik.com/community/code-library/aspnet-ajax/grid/accessing-server-controls-in-a-grid-template-on-the-client.aspx

Bodevain
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Bodevain Svensson
Top achievements
Rank 1
Share this question
or