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

get column(0) cell value on row click client side

4 Answers 383 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 06 Dec 2011, 08:33 PM
My query string in the window.open is not working correctly,
but my real issue is being able to grab the first column's cell value
when someone clicks in a cell on the grid.  So var SITE wouldn't be hard coded, it would get the value
on the client side to pass to the window.open..
I found an example from 2008 on the site, but I can't get it to work
even if I completly replace my code with it.  Any help is appreciated.

<script type=
"text/javascript" >
      function RowClick(sender, args)
      {
          var grid = sender;
          var MasterTable = sender.get_masterTableView();
          var cellindex = args.get_domEvent().target.cellIndex
          var DOS = MasterTable.get_columns()[cellindex].get_uniqueName();
          var SITE = "140006"
          window.open("'Detail.aspx?1=" & DOS & "&2=" & SITE & "',newwindow","toolbar=no,location=no,menubar=no,width=300,height=300,resizable=no,scrollbars=no,top=200,left=250");return false;
      }
   </script>

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Dec 2011, 06:03 AM
Hello,

Try the following java script.
JS:
function RowClick(sender, args)
  {
     var grid = sender;
     var masterTable = grid.get_masterTableView();
     var row = args.get_gridDataItem();
     var cell = masterTable.getCellByColumnUniqueName(row, "UniqueName");
     alert(cell.innerHTML);
  }

Thanks,
Princy.
0
Chris
Top achievements
Rank 1
answered on 07 Dec 2011, 02:41 PM
Thanks much! It appears to not work on a hidden column.  Is that possible to do?
0
Chris
Top achievements
Rank 1
answered on 07 Dec 2011, 03:50 PM
or does that have to be done server side?
0
Princy
Top achievements
Rank 2
answered on 08 Dec 2011, 05:28 AM
Hello,

One suggestion is you can set ClientDataKeyNames of hidden column and access that as shown below.
JS:
function RowClick(sender, args)
{
  var key=args.getDataKeyValue("UniqueName");
  alert(key);
}

Thanks,
Princy.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Chris
Top achievements
Rank 1
Share this question
or