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

Select other grid rows based on column value of selected row inside OnRowSelect() client side function

1 Answer 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ankool
Top achievements
Rank 1
ankool asked on 12 Jul 2011, 01:04 AM
Hello,

I have a grid with multiple row select option set to true. I need to implement a function which is called on grid row select at client side and that function selects other rows in grid based on a column value. For example , Assume grid with 10 rows and 5 columsn,  if I select row 2 and my matching column value is also present in row 4 , row 7 and row 9. Then row 4, 7, and 9 should be automatically selected.

Let me know how to implement this using client side function OnRowSelect ()

Thanks

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Jul 2011, 07:14 AM
Hello Ankool,

You can achieve this by attaching the client event OnRowClick and select the desired rows.
client side:
function OnRowClick(sender, args)
    {
       var dataItem = args.get_gridDataItem();
       var cell = dataItem.get_cell("ColumnUniqueName");
       var txt = cell.innerText;//accessing the cell value.
       dataItem .set_selected(true);
       var Grid = sender;
       var MasterTable = Grid.get_masterTableView();
       for (var i = 0; i < MasterTable.get_dataItems().length; i++)
       {
           var row = MasterTable.get_dataItems()[i];
           var value = parseInt(row.get_cell("ColumnUniqueName").innerText);
           if (row.get_cell("ColumnUniqueName").innerText == "4") //Give your condition.
           {
               row.set_selected(true);
          }
       }
   }

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