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

[Solved] How to place a link to another action in a every column of grid

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alok
Top achievements
Rank 1
Alok asked on 06 Jan 2011, 12:52 PM
Hi,


How can I place a link to another action in a every column of grid 


I want to have link on every cell which can redirect me to some action of some controller. 
Using Server Template i am getting error with Ajax.  
I tried using client template but it is not working.


It will be great help if some one can tell me how can I go about it.


Thanks

1 Answer, 1 is accepted

Sort by
0
megha
Top achievements
Rank 1
answered on 07 Jan 2011, 01:53 PM

There are two solution of this problem:

Solution 1 :
1) Make the grid selectable.
2) Add command to Telerik grid
       .ClientEvents(events => events.OnRowSelected("Grid_onSelect"))
3) Write required code in this javascript function 
      function Grid_onSelect(e) {
         
alert(e.row.cells[0].outerText);
         
document.location.href = "/royaltor/royaltorentry/" + e.row.cells[0].outerText;
   }

Solution 2:
 1) Add command to Telerik grid
       .ClientEvents(events => events.OnLoad("Grid_onLoad"))
2) Write required code in this javascript function 
      function Grid_onLoad(e) {
                var grid = $(this).data('tGrid');
                var gridRows = grid.$rows();
                for(i=0; i<gridRows.length;i++) {
                    for (x = 0; x < gridRows[i].cells.length; x++) {
                        //var a = gridRows[i].cells[x].innerHTML;
                        gridRows[i].cells[x].innerHTML = "<a href='/royaltor/ViewRoyaltor/?strRoyaltorCode=" + gridRows[i].cells[0].innerHTML                                                                                + "&IsEditable=false&strPage=searchpage' class='t-link'>" + gridRows[i].cells[x].innerHTML + "</a>";
      }

 

 

 

 

Tags
Grid
Asked by
Alok
Top achievements
Rank 1
Answers by
megha
Top achievements
Rank 1
Share this question
or