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

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

16 Answers 1054 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Samantha
Top achievements
Rank 1
Samantha asked on 10 Apr 2009, 06:49 AM
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.

16 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 10 Apr 2009, 08:53 AM
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.
0
Greg
Top achievements
Rank 1
answered on 22 Dec 2009, 10:38 AM
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
0
Yavor
Telerik team
answered on 23 Dec 2009, 08:30 AM
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.
0
Greg
Top achievements
Rank 1
answered on 24 Dec 2009, 09:57 AM
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


0
Veli
Telerik team
answered on 29 Dec 2009, 11:47 AM
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.
0
Jimmy Vithalani
Top achievements
Rank 1
answered on 20 Apr 2010, 12:22 PM
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.
0
Veli
Telerik team
answered on 20 Apr 2010, 12:37 PM
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.
0
Jimmy Vithalani
Top achievements
Rank 1
answered on 20 Apr 2010, 12:51 PM
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.
0
Veli
Telerik team
answered on 20 Apr 2010, 05:10 PM
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.
0
NewB
Top achievements
Rank 1
answered on 08 Oct 2010, 12:55 PM
I had this problem on an old version of Telerik (2008), this solution works for me. Thank you
0
Nicolaï
Top achievements
Rank 2
answered on 08 Oct 2010, 01:24 PM
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")
0
Greg
Top achievements
Rank 1
answered on 08 Oct 2010, 01:27 PM
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.
0
Sebastian
Telerik team
answered on 08 Oct 2010, 01:45 PM
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
0
NewB
Top achievements
Rank 1
answered on 08 Oct 2010, 04:04 PM
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.
0
RaY
Top achievements
Rank 1
answered on 20 Sep 2013, 08:42 AM
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.
0
Eyup
Telerik team
answered on 25 Sep 2013, 08:04 AM
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.
Tags
Grid
Asked by
Samantha
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Greg
Top achievements
Rank 1
Veli
Telerik team
Jimmy Vithalani
Top achievements
Rank 1
NewB
Top achievements
Rank 1
Nicolaï
Top achievements
Rank 2
Sebastian
Telerik team
RaY
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or