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

make column unselectable

5 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ashraf
Top achievements
Rank 2
Ashraf asked on 19 Nov 2012, 02:28 PM
hi ,i want to make one of the  columns unselectable  so the user can't select row by clicking on that column  or unselect  or darg mouse to select multi rows in same time (this column have no effect to select or unselect row or rows)

5 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 22 Nov 2012, 11:31 AM
Hi Ashraf,

Please try the following approach:
<ClientEvents OnRowSelecting="preventSelection" OnRowDeselecting="preventSelection" OnRowMouseOver="preventSelection" />
JavaScript:
function preventSelection(sender, args) {
    var clickedCell = args.get_domEvent().target;
    if (clickedCell) {
        var columnName = sender.get_masterTableView().get_columns()[clickedCell.cellIndex].get_uniqueName();
        if (columnName == "ShipName") {
            if (args.set_cancel) {
                args.set_cancel(true);
            }
            sender.ClientSettings.Selecting.EnableDragToSelectRows = false;
        }
        else {
            sender.ClientSettings.Selecting.EnableDragToSelectRows = true;
        }
    }
}

I hope this will prove helpful. Please give it a try and let me know about the result.

Regards,
Eyup
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.
0
Ashraf
Top achievements
Rank 2
answered on 26 Nov 2012, 09:43 AM
thanks Eyup , great your code works fine ,thank you very much .
0
Ashraf
Top achievements
Rank 2
answered on 26 Nov 2012, 01:29 PM
i want something else  why the check box in header that select all rows become unchecked even i select all rows 
0
Eyup
Telerik team
answered on 28 Nov 2012, 09:19 AM
Hello Ashraf,

The provided approach works as expected on my side and the header checkbox gets selected correctly when all of the items are selected.

I suggest you to add this condition to the function if you are using select column:
if (clickedCell) {
    if (clickedCell.tagName == "TD") {

Please provide us the exact steps to reproduce the problematic behavior.

Kind regards,
Eyup
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.
0
Ashraf
Top achievements
Rank 2
answered on 28 Nov 2012, 09:27 AM
thanks Eyup ,i handled it by the following  code 

function preventSelection(sender, args) {
                var clickedCell = args.get_domEvent().target;
                if (clickedCell) {
                    if (clickedCell.cellIndex != undefined) {
                        var columnName = sender.get_masterTableView().get_columns()[clickedCell.cellIndex].get_uniqueName();
                        if (columnName == "SetDetails") {
                            if (args.set_cancel) {
                                args.set_cancel(true);
                                var selectedItemsCount = sender.get_selectedItems().length;
                                var ItemsCount = sender.get_masterTableView().get_dataItems().length;
                                if (selectedItemsCount == ItemsCount) {
                                    $(':checkbox:first').attr('checked'true);
                                }
                            }
                        }
                    }
                }
            }
Tags
Grid
Asked by
Ashraf
Top achievements
Rank 2
Answers by
Eyup
Telerik team
Ashraf
Top achievements
Rank 2
Share this question
or