ClientSelectColumn

11 posts, 0 answers
  1. Naresh
    Naresh avatar
    22 posts
    Member since:
    Oct 2010

    Posted 02 Jun 2011 Link to this post

     

    var row = masterTable.get_dataItems()[index];

     

     

     

    var cell = masterTable.getCellByColumnUniqueName(row, "ClientSelectColumn");

     

     

     

    var chk = cell.getElementsByTagName("input")[0];

     

     

    if(chk.checked)

     

     

    {

     

    ....


    }


    eventhough i select the Check box               chk.checked    is false. 

     

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Jun 2011 Link to this post

    Hello Naresh,

    I am not quite sure about the exact requirement. Here is the code that I tried which worked as expected on an external button click.
    Javascript:

    function Ckecked()
        {
           var masterTable = $find("<%= RAdGrid1.ClientID %>").get_masterTableView();
           for (var index = 0; index < masterTable.get_dataItems().length; index++)
          {
               var row = masterTable.get_dataItems()[index];
               var cell = masterTable.getCellByColumnUniqueName(row, "ClientCol");
               var chk = cell.getElementsByTagName("input")[0];
               if (chk.checked)
               {
                   alert("Ckecked!!");
               }
               else
               {
                   alert("Not Ckecked!!");
               }
           }
       }

    Thanks,
    Shinu.

  3. DevCraft Release
  4. Naresh
    Naresh avatar
    22 posts
    Member since:
    Oct 2010

    Posted 02 Jun 2011 Link to this post

    Shinu,
    Exactly you have understood my requirement.But if try the same code for ClientSelectColumn
    i did not get true for any row iusing the code ,though i select it in the website.
    Do i need to set anything in Radgrid.

  5. Veli
    Admin
    Veli avatar
    2002 posts
    Member since:
    Sep 2012

    Posted 07 Jun 2011 Link to this post

    Hello Naresh,

    I tested this scenario locally and it seems to be working OK. Can you send us the markup of a test page in which you reproduce this issue? Thus we can debug it locally.

    Veli
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. Vinit
    Vinit avatar
    6 posts
    Member since:
    Feb 2012

    Posted 23 Feb 2012 Link to this post

    I have hierarchy rad grid with a Master view and detail table (Level 3) . Grid will have clientSelectcolumn  checkbox in the all the rows and Master table Header. (No check box in detial tables Header). Now I want all the rows of the grid (including detail tables ) to be selected if top header checkbox is selected.
    2. if a checkbox is selected in a row then its child grid should also be selected.

    It seems clientSelect column (AllowMultiRowSelection = true) works only for its level not in hierarchy grid.

    could you please provide code snippet ?
    thanks
    Vinit

  7. Veli
    Admin
    Veli avatar
    2002 posts
    Member since:
    Sep 2012

    Posted 23 Feb 2012 Link to this post

    Hi Vinit,

    Yes, the GridClientSelectColumn works only at a single table level. You can implement the scenario you need using some custom javascript. I have attached a test page to demonstrate. Let me know how this works for you.

    Greetings,
    Veli
    the Telerik team

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.

  8. Vinit
    Vinit avatar
    6 posts
    Member since:
    Feb 2012

    Posted 23 Feb 2012 Link to this post

    Hi veli
    thanks for your support.
    I am getting item as null from

    var

     

    item = args.get_gridDataItem() given in javascript.
    Also I don't want to show Checkbox in detial tables grid. Checkbox should be only in the Master Table header row and all datarows of entire grid.

    though In my project Its seems to be running but Its not running as It was supposed to be running.
    1. select  a Row in the second Level ----> It will select all checkbox in the child grid (say in the child grid there are 4 rows) 
    2. Now  uncheck/deselect two of the rows and let others be checked
    3. Select checkbox in the header of the Master Table view ---> It will select all the Items in the grid except those two rows that I de-selected in the previous operation.

    My requirement is as follows
    1.three Level hierarchy
    2. Master grid Header will have checkbox in the header but none of the detail table grid would have the checkbox in their header.
    3. If I select / deselect Header checkbox in the Master Grid , It should select / deselect all the rows including detail grid upto third Level
    4. If I select  any of the the Items -- I should select child grid rows as well
    5. If a child grid's few rows are selected and few are not selected --- in that case parent row should be intermidate state


  9. Veli
    Admin
    Veli avatar
    2002 posts
    Member since:
    Sep 2012

    Posted 23 Feb 2012 Link to this post

    Hello Vinit,

    For the error you are getting, try adding the following line in the beginning of your gridSelectionChanged function:

    function gridSelectionChanged(sender, args)
    {
        args.get_tableView().get_dataItems();
        var item = args.get_gridDataItem();
        var nestedViews = item.get_nestedViews();
        for (var i = 0; i < nestedViews.length; i++)
        {
            toggleSelectionRecursive(nestedViews[i], item.get_selected());
        }
    }

    On the second issue with selecting the master header checkbox, try the following modified version of the toggleSelectionRecursive function:

    function toggleSelectionRecursive(tableView, selected)
    {
        var items = tableView.get_dataItems();
        for (var i = 0; i < items.length; i++)
        {
            var item = items[i];
            if (item.get_selected() !== selected)
            {
                item.set_selected(selected);
            }
     
            var nestedViews = item.get_nestedViews();
            for (var j = 0; j < nestedViews.length; j++)
            {
                toggleSelectionRecursive(nestedViews[j], selected);
            }
        }
    }

    Finally, on your requirements, I believe almost all of this scenario can be achieved with the approach I demonstrated. I have attached a modified version of the test page that you can try at your side. Note, however, that the grid does not provide an automatic way of representing an "intermediate state" of an item where only some of the child items are selected.

    Veli
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.

  10. Toni
    Toni avatar
    2 posts
    Member since:
    Feb 2012

    Posted 23 Feb 2012 Link to this post

    Can I access GridClientSelectColumn in my C# code (code behind)...
    Actually If I need to traverse entire hierachical Rad grid to know what  hierachy is selected  (Parent child relation) ...Is it possible with GridClientSelectColumn ..

    I need to open a Popup that will show a tree view , in that tree I need to display hierachy selected ...

  11. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Feb 2012 Link to this post

    Hello Toni,

    Try the following code to access GridClientSelectColumn.
    C#:

    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
     if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "MasterTableName")
     {
      GridDataItem item = (GridDataItem)e.Item;
      CheckBox check = (CheckBox)item["UniqueName"].Controls[0];
     }
    }

    -Shinu.

  12. Vinit
    Vinit avatar
    6 posts
    Member since:
    Feb 2012

    Posted 24 Feb 2012 Link to this post


    thanks a lot..
    but I can still see issue with the code...

    Steps to generate issue with the code
    1. Select header checkbox of the Master ---> It select all the checkbox (including details)
    2. Deselect one of the rows of the Mastergrid (first Level) ---> It de-select all the checkboxes of child tables (Level 2 and Level 3 checkboxes)
    3. Now select checkbox of the 2nd Level row (which got de-selected in the step 2 ) ---> It select entire child grid(level 3)
    4. Now de-select header checkbox of the Master table---> we can see that Level 2 and Level 3 checkboxes still selected though it should be de-selected

    I can see that If level 2's checkboxes are not selected and then If I de-select the header checkbox of the Master (level 1 ) javascript does not go to the childs of the level 2---->
    It seems that when I de-select the header checkbox and level 2 checkboxes are already  de-selected (unchecked) It stops the execution and that's why row selecting / deselecting event are not being executed.

    What I think is  that when I select the header checkbox of the Master , GridClientSelectColumn in built functionality is executed which select the rows of the Master grid , that in turn execute the rowselecting/deselecting events that makes the entire grid selected
    but when second level checkboxes are already de-selected and now  If de-select the header checkbox of the Master , 2nd level checkboxes  doesn't need to be de-selected and that is why there is no selection /de-selection of the the rows in the 2nd grid therfore no operation in the third level.

    I am trying to call ._selectAllRows in built method for GridclientSelectColumn but so far no success. I have tried other ways also but could not crack this riddle. Please help

    Vinit

Back to Top
DevCraft Release