locked
How to get the cell values of selected row with using jquery RRS feed

  • Question

  • User-1322298207 posted

    Hello,

    I am using component art datagrid. In my grid i have some columns like name,Po_num,location . I want column values of selected row in a grid.

    Please help me it's urgent.

    Thnaks,

    Thursday, February 16, 2012 1:41 AM

Answers

  • User1954304945 posted

    Hi, it seems that there is no parent with “tr” to $('#' + gridClientId + ' tbody tr'), if you would like to get the cell values of selected row, you can try the following method:

    var gridClientId = '<%=Grid1.ClientID %>';
    
    $(document).ready(function () {
    
    $('#' + gridClientId + ' tbody tr').click(function () {
    var name = $(this).children("td:eq(2)").html();
    var po_num = $(this).children("td:eq(3)").html();
    alert(name);
    alert(po_num);
    
    });
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 16, 2012 9:53 PM

All replies

  • User348806598 posted

    Hi,

    I am not sure about the componet art. But I think once the rowvalue is selected there will be some way you can identify the row. May be they can append a selected CSS class to row. And also the grid will some how get converted to HTML table. Below is the list of many post to work with gridview-

    http://delicious.com/anupdg/gridview+jquery+row

    Thursday, February 16, 2012 1:52 AM
  • User-753139339 posted

    Run your webpage with the row selected and copy and paste the source here in order for any one to help, possbilities here are too broad to be really specific. In most cases a selected row will have a different class designation in the <tr> tag under the assumption the grid is using a table. As is seen in the "Core Features" demo here on the Component Art website:

    http://aspnetajax.componentart.com/control-specific/datagrid/features/core_features/default.aspx

    The selected row has a class of "cart-datagrid-row cart-datagrid-row-selected" as is shown by viewing the source. Use this class to select the values of the <td> elements using jQuery, which would be the column values for the selected row.

    Thursday, February 16, 2012 1:58 AM
  • User-1322298207 posted

    Sorry, I am not getting..

    Thursday, February 16, 2012 2:17 AM
  • User-1322298207 posted

    I did like this:

       var gridClientId = '<%=Grid1.ClientID %>';


              $(document).ready(function () {

                  $('#' + gridClientId + ' tbody tr').click(function () {
                      var row = $(this).parents("tr:first");
                      var name = row.children("td:eq(2)").html();
                      var po_num = row.children("td:eq(3)").html();
                      alert(name);
                      alert(po_num);


                  });
              });    but in alert box i am not getting the value of actual name and po_num i am getting null in alert box..

    what's wrong with this?

    Thursday, February 16, 2012 3:02 AM
  • User-753139339 posted

    Please run the page in a browser and copy and past the source code for you your table you want to select values from.

    Thursday, February 16, 2012 1:00 PM
  • User1954304945 posted

    Hi, it seems that there is no parent with “tr” to $('#' + gridClientId + ' tbody tr'), if you would like to get the cell values of selected row, you can try the following method:

    var gridClientId = '<%=Grid1.ClientID %>';
    
    $(document).ready(function () {
    
    $('#' + gridClientId + ' tbody tr').click(function () {
    var name = $(this).children("td:eq(2)").html();
    var po_num = $(this).children("td:eq(3)").html();
    alert(name);
    alert(po_num);
    
    });
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 16, 2012 9:53 PM