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

How to find the imagebutton in the radgrid in clientside?

6 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
shemein
Top achievements
Rank 1
shemein asked on 22 Sep 2014, 10:29 PM
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.


6 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 23 Sep 2014, 08:13 AM
0
shemein
Top achievements
Rank 1
answered on 23 Sep 2014, 12:26 PM
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
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 23 Sep 2014, 05:26 PM
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
0
shemein
Top achievements
Rank 1
answered on 23 Sep 2014, 05:48 PM
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
0
Jayesh Goyani
Top achievements
Rank 2
answered on 23 Sep 2014, 07:48 PM
Hi,

Can you please provide your code?

Thanks,
Jayesh Goyani
0
shemein
Top achievements
Rank 1
answered on 25 Sep 2014, 01:45 PM
Thanks Jayesh! I figured it out.
Tags
Grid
Asked by
shemein
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
shemein
Top achievements
Rank 1
Share this question
or