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

[Solved] CLient select checkbox cannot disable

1 Answer 132 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John Davis
Top achievements
Rank 2
John Davis asked on 26 Jun 2008, 01:15 PM

I need to disable or make invisible selection check boxes for some rows depending on a value of an item in the row.

The following technique partially works. It prevents the user from selecting certain rows.  But it has 2 problems.

1) It disables entire rows (displays them in light grey).  Instead I want to just disable or make invisible the checkbox for these rows.

2) The user can still check all rows by clicking the checkbox in the header.

This post addresses problem #2:
http://www.telerik.com/community/code-library/submission/b311D-mkmkk.aspx

Notes with this posted project say the problem will be solved in Q1. Is it fixed?  It seems not.
Anyway the script provided "almost works".  But I get an "object needed" message on the line that references HiddenField1

 checkBox = $get($get('HiddenField1').value)

even though I do have the following on the user control:

            <asp:HiddenField ID="HiddenField1" runat="server" />
            <asp:HiddenField ID="HiddenField2" runat="server" />

*** code ***

protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
    {
        GridDataItem dataitem = (GridDataItem)item;

        string scs = dataitem["SCSname"].Text;
        if (scs != "(none)") //disable chkbox
        {
            dataitem.Enabled = false;

            if (dataitem.Selected)
            {
                dataitem.Selected = false;
            }
        }
    }

1 Answer, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 30 Jun 2008, 01:26 PM
Hello John,

Onto your questions:

1) I'm afraid you cannot disable the check box only. Using the GridClientSelectColumn, the checkboxes and respective row selection depends on each other. Thus, disabling the check box actually disables the row selection.

2) I'm sending you the demo from the CodeLibrary I slightly modified (there's just a removed property which setting I removed) which functions properly on my end. I've tested it with the latest official Service Pack 2 of RadControls for ASP.NET AJAX Q1 2008, labeled 2008.1.619. Give it a go and let us know if you need further assistance.

Best wishes,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
John Davis
Top achievements
Rank 2
Answers by
Konstantin Petkov
Telerik team
Share this question
or