make column unselectable

6 posts, 1 answers
  1. Ashraf
    Ashraf avatar
    40 posts
    Member since:
    Aug 2012

    Posted 19 Nov 2012 Link to this post

    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)
  2. Answer
    Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 22 Nov 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ashraf
    Ashraf avatar
    40 posts
    Member since:
    Aug 2012

    Posted 26 Nov 2012 Link to this post

    thanks Eyup , great your code works fine ,thank you very much .
  5. Ashraf
    Ashraf avatar
    40 posts
    Member since:
    Aug 2012

    Posted 26 Nov 2012 Link to this post

    i want something else  why the check box in header that select all rows become unchecked even i select all rows 
  6. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 28 Nov 2012 Link to this post

    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.
  7. Ashraf
    Ashraf avatar
    40 posts
    Member since:
    Aug 2012

    Posted 28 Nov 2012 Link to this post

    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);
                                    }
                                }
                            }
                        }
                    }
                }
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017