Accessing cell content on selection

5 posts, 0 answers
  1. Robert
    Robert avatar
    55 posts
    Member since:
    Aug 2008

    Posted 10 Dec 2008 Link to this post

    Hi,

    I vahe implemented row selection using the EnablePostBackOnRowClick property. How can I access the content of a specific cell in the selected row from the event handler (OnItemCommand)?

    Best regards,
    Robert
  2. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 10 Dec 2008 Link to this post

    Hello Robert,

    Please test the following code-snippets:
    <script language="javascript" type="text/javascript"
        function HandleCellClick(sender, args) 
        { 
            var targetCell = args.get_domEvent().target; 
            sender.get_masterTableView().fireCommand("CellClick", args.get_itemIndexHierarchical() + "|" + targetCell.innerHTML); 
        } 
    </script> 

    <ClientSettings Selecting-AllowRowSelect="true" ClientEvents-OnRowSelected="HandleCellClick" /> 

    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
        if (e.CommandName == "CellClick"
        { 
            string[] args = e.CommandArgument.ToString().Split('|'); 
            RadGrid1.Items[int.Parse(args[0])].Selected = true
            RadAjaxManager1.Alert("Cell contents: \n" + args[1]); 
        } 

    Let me know whether this helps.

    Best regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Robert
    Robert avatar
    55 posts
    Member since:
    Aug 2008

    Posted 11 Dec 2008 Link to this post

    Hi Daniel,

    thank your for your reply. Unfortunately the code you provided does not work for me. It seems that my scenario is slightly different. I am catching the "RowClick" command not "CellClick". So what I actually want is to get access to the selected row and then iterate through it's cells.
    Sorry, I didn't explain that clearly in my original post.

    Best regards,
    Robert
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Dec 2008 Link to this post

    Hello Robert,

    you can try out the following code to achieve the required scenario.
    cs:
    protected void RadGrid2_ItemCommand(object source, GridCommandEventArgs e) 
        { 
            if (e.CommandName == "RowClick") 
            { 
                GridDataItem item = (GridDataItem)e.Item; 
                if (item.Selected) 
                { 
                    foreach (GridColumn col in RadGrid2.Columns) 
                    { 
                        string strtxt = item[col.UniqueName].Text; 
                    } 
                } 
            } 
      } 

    Thanks
    Princy.



  6. sumanth
    sumanth avatar
    11 posts
    Member since:
    Feb 2009

    Posted 01 Apr 2009 Link to this post

    Hi
    Danial

    I am working on RADGRID , Accessing Cell Values.
    I am trying with your code.
    BUT My Scenario is little bit different 
    That looks like this
    All the dataTypes in the grid are same(int).
    We have to select any cell (Multiple Selection Also) 
    I need the same value to be displayed in ToolTip
    If we selected Multipule Cells, I need the sum of the values of selection in the ToolTip.

    Plz help me if U have any idea how to achive the same plz tell me


    Thanks in Advance
    Sumanth

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017