Find Control in the event OnBatchEditOpening

6 posts, 0 answers
  1. cesar
    cesar avatar
    9 posts
    Member since:
    Apr 2015

    Posted 14 Sep 2015 Link to this post

    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.

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2184 posts

    Posted 16 Sep 2015 Link to this post

    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
  3. Azam
    Azam avatar
    2 posts
    Member since:
    Nov 2014

    Posted 09 Dec 2018 in reply to Viktor Tachev Link to this post

    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>

  4. Eyup
    Admin
    Eyup avatar
    3644 posts

    Posted 11 Dec 2018 Link to this post

    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.
  5. Azam
    Azam avatar
    2 posts
    Member since:
    Nov 2014

    Posted 11 Dec 2018 in reply to Eyup Link to this post

    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>

  6. Eyup
    Admin
    Eyup avatar
    3644 posts

    Posted 14 Dec 2018 Link to this post

    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.
Back to Top