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

Client select coulmn

3 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Naresh
Top achievements
Rank 1
Naresh asked on 26 May 2011, 10:52 AM
Hi telerik team,

I  want to enable and make  the client select column check boxes checkable in grid by using the follwoing code snipped
for (var row = 0; row <  MasterTable.get_dataItems().length; row++)
           {
            MasterTable.get_dataItems()[row]._element.disabled=false;
            MasterTable.get_dataItems()[row].get_cell("ClientSelectColumn").disabled=false;
             }

but the i could not check the checkboxes in every row it is still disable.
          

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 May 2011, 11:37 AM
Hello Naresh,

By default the ClientSelectColumn checkBoxes are Enabled. No need to explicitly Enable it. It allows you to select the GridRows by checking the CheckBoxes.

Also take a look at the following documentation.
Column types.

Thanks,
Shinu.
0
Naresh
Top achievements
Rank 1
answered on 26 May 2011, 07:34 PM
Shinu,
Sorry if i have not informed you about my requirement properly,
 I could enable  all the rows in grid but the checkbox in the grid is still greyed out but i could check it.
or (var row = 0; row <  MasterTable.get_dataItems().length; row++)
           {
            MasterTable.get_dataItems()[row]._element.disabled=false;
            MasterTable.get_dataItems()[row].get_cell("ClientSelectColumn").disabled=false;
             }
0
Accepted
Shinu
Top achievements
Rank 2
answered on 27 May 2011, 07:44 AM
Hello Naresh,

You can achieve this by attaching onclick event to the Header CheckBox. Then from client side loop through each row and then access the ChecckBox and set checked to true if its enabled.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridHeaderItem)
        {
            GridHeaderItem item = (GridHeaderItem)e.Item;
            CheckBox chk = (CheckBox)item["ClientColumnUniqueName"].Controls[0];
            chk.Attributes.Add("onclick", "check();");//attatching the event.
        }
    }

Javascript:
function Check()
 {
   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, "ClientColumnUniqueName");
            var chk = cell.getElementsByTagName("input")[0];//accessing the CheckBox
            if (chk.disabled)
            {
                chk.checked = false;
            }
            else
            {
                chk.checked = true;
            }
        }
 }

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