How to find the imagebutton in the radgrid in clientside?

7 posts, 1 answers
  1. shemein
    shemein avatar
    28 posts
    Member since:
    Mar 2014

    Posted 22 Sep 2014 Link to this post

    Hi, 
    I have a Radgrid  with :
    <telerik:GridTemplateColumn UniqueName="Restricted" HeaderText="Restrict" FilterControlAltText="Filter Restricted column" Reorderable="False" Resizable="False" ShowSortIcon="False">
    <ItemTemplate>
    <asp:CheckBox ID="cbRistrict" runat="server" AutoPostBack="true" OnCheckedChanged="cbRistrict_OnCheckedChanged" ></asp:CheckBox>

    <asp:ImageButton ID="cbRestrictedImageButton" runat="server" ImageUrl="~/Images/Lock-Restricted.png" ImageAlign="Baseline"></asp:ImageButton>

    </ItemTemplate>
                                                                                                                     
    </telerik:GridTemplateColumn>

    How to find the imagebutton in the radgrid in clientside?

    I have tried :
    var j = $get("<%=IndexHidden.ClientID %>");
    var grid = $find("<%=ToolkitSections.ClientID %>");
    var masterTable = grid.get_masterTableView();
    var gridItemElement = masterTable.get_dataItems()[j.value].findElement("cbRestrictedImageButton");

    and even


    var gridItemElement = masterTable.get_dataItems()[j.value].findControl("cbRestrictedImageButton");

    but none of them is working well. would you please help me to find the imagebutton?

    FYI: imagebutton is invisible by default and j is the index of selected item(checkbox) in radgrid.


  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 23 Sep 2014 in reply to shemein Link to this post

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. shemein
    shemein avatar
    28 posts
    Member since:
    Mar 2014

    Posted 23 Sep 2014 Link to this post

    Hi Jayesh,

    Thanks for your answer. I had tried your blog before and none of them worked for me:(. it is so strange that the code can find the checkbox  but it can't find the imageButton. Do you have any more idea? I really need it as soon as possible.

    Thanks
  5. Answer
    Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 23 Sep 2014 in reply to shemein Link to this post

    Hi,

    Sorry its my mistake as you have already mention that the imagebutton is invisible.
    If button is visible="false" then we can not access the imagebutton from client side.

    <telerik:GridTemplateColumn UniqueName="Restricted" HeaderText="Restrict" FilterControlAltText="Filter Restricted column" Reorderable="False" Resizable="False" ShowSortIcon="False">
                              <ItemTemplate>
                                  <asp:CheckBox ID="cbRistrict" runat="server" AutoPostBack="true" OnCheckedChanged="cbRistrict_OnCheckedChanged"></asp:CheckBox>
                                  <div style="display: none;">
                                      <asp:ImageButton ID="cbRestrictedImageButton" runat="server" ImageUrl="~/Images/Lock-Restricted.png" ImageAlign="Baseline"></asp:ImageButton>
                                  </div>
                              </ItemTemplate>
     
                          </telerik:GridTemplateColumn>

    In-place of visible="false" please use display="none". If you used visible property than the imagebutton will not rendered in browser.
    so, we can not access it on browser.

    Let me know if any concern.

    Thanks,
    Jayesh Goyani
  6. shemein
    shemein avatar
    28 posts
    Member since:
    Mar 2014

    Posted 23 Sep 2014 in reply to Jayesh Goyani Link to this post

    Thanks Jayesh! you are amazing!

    Another little question. when I click on the checkbox to open a radwindow as a pop up page and set the checkbox.checked =true in my javascript it doesn't work and checkbox is empty. Do you have any idea how to check the checkbox when I click on it using javascript?

    Thanks
  7. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 23 Sep 2014 in reply to shemein Link to this post

    Hi,

    Can you please provide your code?

    Thanks,
    Jayesh Goyani
  8. shemein
    shemein avatar
    28 posts
    Member since:
    Mar 2014

    Posted 25 Sep 2014 in reply to Jayesh Goyani Link to this post

    Thanks Jayesh! I figured it out.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017