Problems with selection in grid

7 posts, 0 answers
  1. Tracy
    Tracy avatar
    7 posts
    Member since:
    Sep 2012

    Posted 27 Sep 2012 Link to this post

    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?
  2. Tracy
    Tracy avatar
    7 posts
    Member since:
    Sep 2012

    Posted 03 Oct 2012 Link to this post

    Is there a better method to highlight the checked rows?
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Brandon
    Brandon avatar
    18 posts
    Member since:
    Jul 2012

    Posted 07 Oct 2012 Link to this post

    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
  5. Tracy
    Tracy avatar
    7 posts
    Member since:
    Sep 2012

    Posted 07 Oct 2012 Link to this post

    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
  6. Brandon
    Brandon avatar
    18 posts
    Member since:
    Jul 2012

    Posted 08 Oct 2012 Link to this post

    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
  7. Brandon
    Brandon avatar
    18 posts
    Member since:
    Jul 2012

    Posted 08 Oct 2012 Link to this post

    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
  8. Richard
    Richard avatar
    4 posts
    Member since:
    Oct 2012

    Posted 01 Nov 2012 Link to this post

    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?
Back to Top
UI for ASP.NET MVC is VS 2017 Ready