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

Find Control in the event OnBatchEditOpening

5 Answers 196 Views
Grid
This is a migrated thread and some comments may be shown as answers.
cesar
Top achievements
Rank 1
cesar asked on 14 Sep 2015, 05:56 AM

Hello, how can I find a textbox control using the event OnBatchEditOpening?

I have created a column template.

 

<telerik:GridTemplateColumn HeaderText="Target" UniqueName="target" HeaderStyle-Width="360px">
<HeaderStyle Width="360px" />
<ItemTemplate>
<asp:Literal Text='<%# (Eval("target").ToString()) %>' runat="server" ID="literal_target"></asp:Literal>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadTextBox runat="server" ID="txt_target" TextMode="MultiLine" Width="100%"  />          
</EditItemTemplate>

</telerik:GridTemplateColumn>​

 

Thank you.

5 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 16 Sep 2015, 02:25 PM
Hello Cesar,


In order to get reference to the RadTextBox in the EditItemTemplate you can use the OnBatchEditOpened event. The handler would look similar to the following:


function batchEditOpened(sender, args) {
    var grid = sender;
    var batchEditManager = grid.get_batchEditingManager();
    var masterTable = grid.get_masterTableView();
 
    if (args.get_columnUniqueName() == "target") {
        var textBox = $telerik.findControl(args.get_cell(), "txt_target");
 
        // add custom logic here
    }
}


Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Azam
Top achievements
Rank 1
answered on 09 Dec 2018, 11:43 AM

I want to access both Literal in ItemTemplate and Textbox in EditItemTemplate in this event. Is this possible?

My scenario is, I want to set hidden input(placed in Item Template) value on BatchEditCosed Event. I will get value from Dropdown in EditItemTemplate. This is because, I want to save all rows in grid on server side, instead of using BatchEditing update/save events. And EditItemTemplate control is not accessible on server side, on Button Click Event.

<telerik:GridTemplateColumn HeaderText="Category" HeaderStyle-Width="150px" UniqueName="Invoice_Category_ID" DataField="Invoice_Category_ID">
                        <ItemTemplate>
                            <input id="hdnCategory" type="hidden" runat="server" value="" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox RenderMode="Lightweight" runat="server" ID="CategoryDropDown" DataValueField="Invoice_Category_ID"
                                DataTextField="Description" OnItemsRequested="CategoryDropDown_ItemsRequested"  EnableLoadOnDemand="true">
                            </telerik:RadComboBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>

0
Eyup
Telerik team
answered on 11 Dec 2018, 04:39 PM
Hello Azam,

You can check the sample at the end of this article for accessing controls from other cells:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing/validation

You can also check the following code-library:
https://www.telerik.com/support/kb/aspnet-ajax/details/access-telerik-controls-on-client-side

In addition, I am attaching a sample RadGrid web site with accessing the value when it is present in the batch manager.

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Azam
Top achievements
Rank 1
answered on 12 Dec 2018, 01:03 AM

Hi Eyup,

Thanks for response, but this is not something I need. I can get reference of control placed in edititemtemplate or its value. But I cannot get reference of control placed in ItemTemplate. Like in example provided by me. I want to set value of hidden input control, when value in dropdown changes or when BatchEditClosed. Now I know, how to get value of "CategoryDropDown" placed in edititemtemplate but I can't get "hdnCategory" placed in ItemTemplate of same column. So I can store value for later use.

And I have a reason to do this. On server side, I want to access dropdown selected value for each row on button click.


<telerik:GridTemplateColumn HeaderText="Category" HeaderStyle-Width="150px" UniqueName="Invoice_Category_ID" DataField="Invoice_Category_ID">
                        <ItemTemplate>
                            <input id="hdnCategory" type="hidden" runat="server" value="" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox RenderMode="Lightweight" runat="server" ID="CategoryDropDown" DataValueField="Invoice_Category_ID"
                                DataTextField="Description" OnItemsRequested="CategoryDropDown_ItemsRequested"  EnableLoadOnDemand="true">
                            </telerik:RadComboBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>

0
Eyup
Telerik team
answered on 14 Dec 2018, 02:43 PM
Hi Azam,

You can replace the HTML input element with a server-side HiddenField control and access it on server-side by using the gridItem.FindControl("MyHiddenFieldID") approach:
https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hiddenfield(v=vs.110).aspx

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
cesar
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Azam
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or