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

GridClientSelectColumn not getting set?

6 Answers 347 Views
Grid
This is a migrated thread and some comments may be shown as answers.
TonyG
Top achievements
Rank 1
TonyG asked on 21 Mar 2012, 10:18 PM
I'm populating my RadGrid.DataSource with a strongly typed collection class. One of the Properties of the class is "Apply", which is a Boolean.  All of the other columns in the grid populate except for the GridClientSelectColumn.  The checkboxes are available for checking, they're just not pre-checked from data.

Can anyone think of anything obvious that I might be missing?

I added an ItemDataBound event but for some reason that causes all rows to not display.  I might have missed something basic there too, but for now I don't care.  I'd just like to get specific checkboxes to pre-select when the form loads.

Thanks!

<telerik:GridClientSelectColumn UniqueName="Apply">
    <HeaderStyle Width="50px" />
    <ItemStyle Width="50px" />
</telerik:GridClientSelectColumn>

6 Answers, 1 is accepted

Sort by
0
James Campbell
Top achievements
Rank 1
answered on 22 Mar 2012, 02:52 AM
TonyG,

I am not sure you would want to use the GridClientSelectColumn for this. This allows you to select grid rows client-side automatically when you change the status of the checkbox to checked

http://www.telerik.com/help/aspnet-ajax/t_telerik_web_ui_gridclientselectcolumn.html

You most likely would want to use the GridCheckBoxColumno if you want it databound.

http://www.telerik.com/help/aspnet-ajax/t_telerik_web_ui_gridcheckboxcolumn.html

Hope this helps.
Thanks,
Jim

If this helped answer your question, please mark this as answered, thank you.
0
TonyG
Top achievements
Rank 1
answered on 22 Mar 2012, 03:35 AM
Jim, that's funny - that's what I had working a few days ago, then saw the GridClientSelectColumn and the nice Select All functionality for the header, and I swapped column types.

The thing is that the GridClientSelectColumn is such an elegant solution. All of the checks are in state on the client and available in a single postback. There's no need to deal with a template column or multiple postbacks. The Select/DeSelect All functionality is built-in to the header.

The difference, as you say, is that in the postback we're processing Selected rows, and not processing rows that happen to have a selected Boolean=true column with a checkbox to render the data.  For my current application that's fine!  This grid is display only and all I'm doing is getting the new checkbox/selected status on postback.  What I'm understanding is that I need to ensure multi-select is on, run though the collection of data after DataBind, and set each row with a check as a selected row.

Now that I've clarified the purpose, do you agree with that approach?  And is there a more elegant way to do that?  I'd think it would simply get the Selected status from the value of column referenced in the UniqueName.  Maybe there is another property for this purpose?

If GridCheckBoxColumn is really the best solution, is there an example somewhere for putting a Select All checkbox in the grid header so that it doesn't need to be outside the grid?  :)

Thanks!

0
TonyG
Top achievements
Rank 1
answered on 22 Mar 2012, 06:43 AM

Jim tipped me off as to the nature of the problem. (Thanks man!)  The matter is solved using the GridClientSelectColumn with the following fairly common code:

protected void gridActivities_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        item.Selected = ((Activity)(item.DataItem)).Apply;
    }
}

This is a table of possible Activities related to some event and Apply is the Boolean for where the user decides whether a specific Activity applies to the event.
0
James Campbell
Top achievements
Rank 1
answered on 22 Mar 2012, 07:45 AM
TonyG,

Glad I could help. Please remember to accept an answer and mark this post as resolved.

Thank you,
Jim
0
TonyG
Top achievements
Rank 1
answered on 22 Mar 2012, 08:04 AM
Off-topic: unlike StackOverflow this site only has primitive mechanisms for flagging forum postings. This is surprising given the capable toolkit being used.

The solution you provided was not the correct solution to this specific problem, though it was inspirational and you deserve some sort of credit.  As someone who frequents these forums I wouldn't want to accept that the solution is to use a different column type when that's not required in this scenario.

Unless I'm missing something in the screen I'm looking at, we don't have a way to flag forum postings as resolved, vote on threads or individual postings (where I would have certainly given you a +1), or to flag our own solution as being the ultimate solution.

Perhaps Telerik is planning another round of forum makeovers as they have in the past.  I would welcome the changes above, tags, and the ability to link messages and view linked threads.  In this new world of social media I think it's time for old 1990's style forums to evolve so that we can make better use of them.
0
Accepted
James Campbell
Top achievements
Rank 1
answered on 22 Mar 2012, 05:26 PM
TonyG, Once you mark a post as answered it will update thread. MVPs get points for accepted answers. You can also mark your post as the answer. It helps when sorting through posts looking for unresolved questions. Thank you, Jim
Tags
Grid
Asked by
TonyG
Top achievements
Rank 1
Answers by
James Campbell
Top achievements
Rank 1
TonyG
Top achievements
Rank 1
Share this question
or