All the selected row will be automatically deselect once i click any row in the radgrid

17 posts, 0 answers
  1. Samantha
    Samantha  avatar
    18 posts
    Member since:
    Sep 2008

    Posted 10 Apr 2009 Link to this post

    i have a radgrid which allowed for multirowselection = true.  i can select more than one row by check the select column.  All the selected rows will be deselected if i click on any row or record inside the grid.  Is there any way that i can remain all those selected rows.

  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 10 Apr 2009 Link to this post

    Hello Samantha ,

    Indeed, the behavior that you described is observed. However, it is expected.
    Such an action will trigger the onRowSelecting for the clicked row, and onRowDeselecting for all currently selected rows. This gives you a chance to cancel out these events, potentially reverting this behavior.
    I hope this suggestion helps.

    Regards,
    Yavor
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Greg
    Greg avatar
    56 posts
    Member since:
    Mar 2009

    Posted 22 Dec 2009 Link to this post

    Hello.
    I am using the latest release of telerik controls and I'm surprised the above functionality is still not implemented. All we need as the row click work exactly the same way as row checkbox click. The suggestions in this post have bugs with select/deselect all checkbox, so there is no valid solution at the moment.

    If you do have one, can u please point it out to us.

    Thanks
  5. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 23 Dec 2009 Link to this post

    Hello Greg,

    Basically, there are pros and cons for both types of behavior. What you find intuitive, may be not so well accepted but other users/developers. Nevertheless, you can use the events mentioned earlier, to come up with a custom implementation, which works around this behavior.
    Let me know how such an approach meets your requirements.

    Sincerely yours,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Greg
    Greg avatar
    56 posts
    Member since:
    Mar 2009

    Posted 24 Dec 2009 Link to this post

    Yavor,

    thanks for your reply. Like I said, unfortunately, overriding these event will result in "Select All" checkbox not working properly -- on de-select all it only de-selects one row instead of all.
    Albeit, if you have a working example, please do point it out to me.

    Regards


  7. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 29 Dec 2009 Link to this post

    Hi there,

    @Greg: Unfortunately, there is no silver bullet approach that enables all scenarios working all at once. You need to choose whether you want to enable toggling row selection by clicking on the row, or using checkboxes for that. There is currently no supported approach  that enables you to both toggle rows on row click and use the checkboxes in the client select column.

    The forum post you are referring to in your previous post demonstrates the second approach and does not claim to be compatible with check boxes in any way. If you want to make things working with checkboxes only, you will need to disable row selection on row click. Actually, with version 2009.Q3.SP1 of Telerik RadControls, there is a property RadGrid.ClientSettings.Selecting.UseClientSelectColumnOnly that does exactly that, i.e. enables you to select/deselect rows only through the client select column and not on row click. If you have enabled multi-row selection, however, dragging to select still works.

    If you are using older version and do not want to or cannot upgrade, here is a workaround that you can include in your page:

    function gridCreated(sender, args)
    {
        WrapSelectionClick(sender._selection, ourClick);
     
        setTimeout(function()
        {
            var grid = $find(sender.get_id());
            var master = grid.get_masterTableView();
     
            //If you do not want to disable drag-to-select, comment this line out
            $clearHandlers(master.get_element().tBodies[0]);
     
        }, 0);
    }
     
     
    WrapSelectionClick = function(context, wrapper)
    {
        var fn = context._click;
        context._click = function()
        {
            var args = Array.prototype.slice.call(arguments);
            var origDelegate = function() { return fn.apply(context, args); };
            return wrapper.apply(context, [origDelegate].concat(args));
        };
    };
     
    ourClick = function(origFn, e)
    {
         
        var el = (e.target) ? e.target : e.srcElement;
        if (!el.tagName) return;
     
        if (el.tagName.toLowerCase() == "input" &&
                                    el.type.toLowerCase() == "checkbox" &&
                                    (el.id && el.id.indexOf("SelectCheckBox") != -1))
        {               
            origFn(e);
        }
    };

    The above code enables you to select only through the check boxes in the client select column. You can optionally enable or disable drag-to-select by commenting the specified line of code on and off.

    @Samantha: I think this approach is what you need. Is it working OK? Again, upgrading to the latest version of RadControls, you have a ready property for this case.

    Sincerely yours,
    Veli
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Jimmy Vithalani
    Jimmy Vithalani avatar
    22 posts
    Member since:
    Mar 2010

    Posted 20 Apr 2010 Link to this post

    Hello Veli,

    As you said, I can not install newer version (Q3) and have to find workaround in Q2 only.

    The javascript code which you shown works fine, and does not allow to select by clicking on the row.
    But it has removed the selected style also for the rows. So, now even if I select a row by clientselect column checkbox,
    the style/color of the row does not change.

    I would have liked it that way even, but the problem is, I have some already selected rows, which I make .Selected = true on RowDataBound event. And they have a default selected style based on the skin.

    How can I change the selected style same as my current skin? As I am working on different skins.

    Thanks.
    Jimmy.
  9. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 20 Apr 2010 Link to this post

    Hi Jimmy,

    Cannot verify this. Attaching a test page. Can you reproduce the loss of styles there?

    All the best,
    Veli
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  10. Jimmy Vithalani
    Jimmy Vithalani avatar
    22 posts
    Member since:
    Mar 2010

    Posted 20 Apr 2010 Link to this post

    Hello Veli,

    As I said, I can not use UseClientSelectColumnOnly property because I am using an older version.

    After removing that when I run your example, I am able to select rows by clocking on them.

    I used your js code from the second last post, and it worked for me, and I am not able to select row by clicking now.

    I do not have any extra styles for Items or SelectedItems. I am using skin Office2007.

    Now when I click on checkbox to select a row, it does not change style of row.

    But when I say Item.Selected = true in OnItemDataBound event of grid, I get the selected rows in different style, which is default for selected items in Office2007.

    I would like not to have styles at all or have the same style even If I select from server side or client side.

    Can you help me on this?

    Thanks.
    Jimmy.
  11. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 20 Apr 2010 Link to this post

    Hello Jimmy,

    Attaching the sample page running in a test project that references 2009.Q2 version of RadGrid. I am getting everything OK. Can you, please, verify.

    Sincerely yours,
    Veli
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  12. NewB
    NewB avatar
    5 posts
    Member since:
    Jan 2010

    Posted 08 Oct 2010 Link to this post

    I had this problem on an old version of Telerik (2008), this solution works for me. Thank you
  13. Nicolaï
    Nicolaï avatar
    160 posts
    Member since:
    Apr 2008

    Posted 08 Oct 2010 Link to this post

    Hello,

    Just adding my opinion:
    I find the default behavior very weird and annoying as well. I really don't see the "pros" to this behavior.
    (=All others get deselected when clicking on a row)

    (edit: And the selected styles are generally too invasive, too "violent")
  14. Greg
    Greg avatar
    56 posts
    Member since:
    Mar 2009

    Posted 08 Oct 2010 Link to this post

    I couldn't agree more - yet Telerik have argued this point with me for a number of years.

    The default behaviour is confusing and has few benefits.
  15. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 08 Oct 2010 Link to this post

    Hello guys,

    You can disable the client selection on row click and select rows via the GridClientSelectColumn checkboxes only (see the configuration option from this demo) - thus your previous selection will be kept when you click outside of the checkboxes for selection.

    Best regards,
    Sebastian
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  16. NewB
    NewB avatar
    5 posts
    Member since:
    Jan 2010

    Posted 08 Oct 2010 Link to this post

    I guess this demo only apply to new version of Telerik, my campany is using 2008 version. The javascript code given aboved solved my problem, really helpful.

    I do agreed this default behaviour seems quite confusing. Customers using our website are not technical at all, they normally need to select all records (hundreds or thousands) then carefully deselect some of the items and do an export, they feel really upset if they accidently click somewhere else ouside of the checkbox and all the selection gone, they have to do it again.
  17. RaY
    RaY avatar
    3 posts
    Member since:
    Sep 2013

    Posted 20 Sep 2013 Link to this post

    I'm trying the latest version of telerik controls and facing the same problem.

    I don't want to automatically deselect all rows when I click any row in the grid because I don't like this behaviour and it only does to the current page. I'm trying the UseClientSelectColumnOnly property but it doesn't work if you don't use a GridClientSelectColumn (I'm using a custom select column).

    Is there any way to disable that behaviour without using GridClientSelectColumn or the workaround that you suggest?

    Thanks in advance.
  18. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 25 Sep 2013 Link to this post

    Hello Ray,

    Please refer to the last post of the following code-library:
    http://www.telerik.com/community/code-library/aspnet-ajax/grid/get-selected-items-through-all-pages.aspx#2714041

    Hope this helps.

    Regards,
    Eyup
    Telerik
    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 the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017