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

Cell update

1 Answer 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
lm
Top achievements
Rank 1
lm asked on 27 Jun 2013, 08:37 PM
I am pretty new to telerik I am playing around with this for last 2 days. I need your help.  I have a grid with Templatecolumns which have text boxes as their edititem there are about 12 such columns. When I edit one cell of a row the cells on its left  need to be updated. 

I used changeevent of the textbox to capture the item. Not sure if that is the right approach.I 
I coudl get the rowindex of the cell being edited, how do I fidn the column being edited. 

TIA

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 02 Jul 2013, 12:57 PM
Hi Levanya,

I would like to ask you to elaborate more on your scenario. Do you want to change the values client-side or server-side. If you want to change the value client-side you can directly obtain a reference to the other text box by modifying the id of the sender and using $find. For example if you have two columns defined like this:
<telerik:GridTemplateColumn DataField="A" UniqueName="column1">
                        <ItemTemplate>
                            <%# Eval("A") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadTextBox runat="server" Text='<%# Bind("A") %>' ID="TextBox1EditItemTemplate"></telerik:RadTextBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn  DataField="B" UniqueName="column2">
                        <ItemTemplate>
                            <%# Eval("B") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadTextBox runat="server" ClientEvents-OnValueChanged="ValueChanged"
                                Text='<%# Bind("B") %>' ID="TextBox2EditItemTemplate"></telerik:RadTextBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>

In the ValueChanged event handler you can change the text in the other column like demonstrated below:
function ValueChanged(sender, args) {
           $find('<%=RadGrid1.ClientID%>').get_masterTableView().get_dataItems();
           var textBoxInColumn2 = $find(sender.get_id().replace("TextBox2EditItemTemplate", "TextBox1EditItemTemplate"));
           textBoxInColumn2.set_value(args.get_newValue());
       }

In attachments you can find the sample website in which this approach is implemented.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
lm
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or