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

Problems with selection in grid

6 Answers 260 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tracy
Top achievements
Rank 1
Tracy asked on 27 Sep 2012, 10:48 AM
I have a grid with a checkbox in each row to select the row
How can I highlight the checked rows?

I used the following codes in the Change event
var grid = $("#grid").data("kendoGrid");
grid.select($("tr[data-uid]").has("input[name=checkboxName]:checked"));

However, when I unselect a row, the unselected row is still highlight
Can I disable user to select a row, but only select row by javascript?

6 Answers, 1 is accepted

Sort by
0
Tracy
Top achievements
Rank 1
answered on 03 Oct 2012, 07:38 AM
Is there a better method to highlight the checked rows?
0
Brandon
Top achievements
Rank 2
answered on 07 Oct 2012, 02:30 PM
Hi Tracy,

Is the checkbox required for selecting individual rows? If not, it's quite easy to allow users to select rows by clicking on them, and you can enable multiple row selection by passing "multiple, row" in the selectable configuration option (http://docs.kendoui.com/api/web/grid#selectable stringdefault):

$("#grid").kendoGrid({
     selectable: "multiple, row"
 });
Hope that helps!

Brandon Satrom
0
Tracy
Top achievements
Rank 1
answered on 08 Oct 2012, 02:01 AM
Hi Brandon,

Thanks for your reply

However, we don't want user to click Ctrl key for multi-select
so we provide checkboxs for them to select rows
Is there a way of highlight rows using checkbox?

Tracy
0
Brandon
Top achievements
Rank 2
answered on 08 Oct 2012, 09:40 AM
Hi Tracy,

Thanks for the additional information. I've re-created your scenario in an JSBin example and you can look at it here:

http://jsbin.com/ajojor/6/

As you can see, while this enables using checkboxes to trigger a grid.select(), it's not a viable solution because the default behavior of the grid is forcing the entire row to be selected each and every time I click anywhere in the row, including when I "uncheck" a checkbox.

So, long story short, what you're attempting to do isn't possible AFAIK with checkboxes inside of the grid itself. You could certainly move them outside of the grid, but I will also speak with the engineering team and see if there is a more-acceptable workaround or an opportunity for a new feature in a future release.

Thanks,

Brandon
0
Brandon
Top achievements
Rank 2
answered on 08 Oct 2012, 02:12 PM
Tracy,

One small update to the JSBin I shared earlier and now it works:

http://jsbin.com/ajojor/15/edit

In this case, I added a call to clearSelection() to the grid, which ensures that only the checked rows are selected.

Hope that helps!

Brandon
0
Richard
Top achievements
Rank 1
answered on 01 Nov 2012, 04:56 PM
This works for me too. However, the check marks are lost when I page, and therefore they are not selected. How can I maintain this during paging?
Tags
Grid
Asked by
Tracy
Top achievements
Rank 1
Answers by
Tracy
Top achievements
Rank 1
Brandon
Top achievements
Rank 2
Richard
Top achievements
Rank 1
Share this question
or