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

how to implement clearing a row by clicking on a link in a cell

4 Answers 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rebecca Peltz
Top achievements
Rank 1
Rebecca Peltz asked on 18 Jun 2010, 04:48 AM
I want to clear all the cells (or set select indexes) based on clicking on a link in a cell in the row.  I want to do this client side.  I have an onclientclick event on an asp:link in a template column in a grid

 </telerik:GridTemplateColumn> 
                     <telerik:GridTemplateColumn UniqueName="Clear" HeaderText=""
                        <ItemTemplate> 
                            <asp:LinkButton runat="server" ID="lnkClear" OnClientClick="RowClear(this);return false;" Text="Clear"></asp:LinkButton> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 

In the RowClear javascript function, I want to get the row and then the GridDataItem based on the link.  Then I want to be able to access all the cells in the row.  Can you give me a pointer as to how to get to the other cells from the cell that contains the link that was clicked.  I think it has to do with getting the parent, but just coding sender.parent doesn't work.

Thanks for your help!

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Jun 2010, 07:54 AM
Hello Rebecca,

Here is one suggestion to accomplish this.

Access the LinkButton from code behind in 'ItemCreated' event and attach the "onclick" event by passing the row's ItemIndex.

In the client side event handler get the index passed, and access the corresponding row to change the cell values. The code shown in the forum will assist you to access the corresponding row from client side code.

Hope this would help you to get started.


Regards,
Shinu.
0
Rebecca Peltz
Top achievements
Rank 1
answered on 18 Jun 2010, 03:09 PM
I'm able to find the cell.  Once there I'm trying to 'unselect'.  I use the code below and it works in firefox but not IE.

 function RowClear(link) { 
        var index = link.attributes["index"].value; 
        alert(index); 
        var MasterTable = $find(gridName).get_masterTableView(); 
        var row = MasterTable.get_dataItems()[index]; 
        //ClearSelect(row, 'SchoolName'); 
          var cell = MasterTable.getCellByColumnUniqueName(row, 'SchoolName'); 
            var cellcelltext = cell.innerHTML; 
            alert(celltext); 
            var celltextcelltext = celltext.replace('selected="selected"', '') 
            var celltextcelltext = celltext.replace('valuevalue="0"', 'value="0" selected="selected" '); 
            alert(celltext); 
            cell.innerHTML = celltext
        return false; 
    } 


Also I need to hide this column under some circumstances but I'm not sure the best way to hide a column.

Any ideas or links ?

Thanks!
0
Rebecca Peltz
Top achievements
Rank 1
answered on 18 Jun 2010, 03:23 PM
I found my IE problem - but I'm still look for a way to hide columns and this could be server side.
0
Rebecca Peltz
Top achievements
Rank 1
answered on 18 Jun 2010, 03:37 PM
found my hide column answer too
RadGridChoice.MasterTableView.GetColumn("Clear").Display = false

Tags
Grid
Asked by
Rebecca Peltz
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Rebecca Peltz
Top achievements
Rank 1
Share this question
or