using checkboxes for row selection

3 posts, 1 answers
  1. Joe
    Joe avatar
    144 posts
    Member since:
    May 2012

    Posted 31 Jan Link to this post

    I'm putting together a grid which displays results for a document search.  In the grid itself, instead of showing the row Id, I have a checkbox.  What I'd like to do is twofold:

    1. Add a check box column header that'll select all rows when checked (I've seen examples that use a specific boolean field, which my grid doesn't have nor use...  I just want to go through each row displayed and check the checkbox, but it is not dependent upon any other column.

    2. Get all the selected row IDs to pass into a controller.  Not really pertinent, but what that controller will do is look for corresponding rows in the database, extract the document information in order to zip them all up together.

    Any help would be greatly appreciated...

  2. Answer
    Dimo
    Admin
    Dimo avatar
    8369 posts

    Posted 02 Feb Link to this post

    Hi Joe,

    An example showing a header cell checkbox is available at:

    http://demos.telerik.com/aspnet-mvc/grid/headertemplate

    My understanding is that the checked rows will also be selected. From this point of view, you can obtain the selected rows, obtain the underlying data item for each of them, and finally, get the desired IDs.

    - how to obtain the selected rows
    http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#methods-select

    - how to obtain the data item for a specific table row
    http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#methods-dataItem

    - how to get a data field value from a data item object
    http://docs.telerik.com/kendo-ui/api/javascript/data/model#methods-get


    Regards,
    Dimo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Joe
    Joe avatar
    144 posts
    Member since:
    May 2012

    Posted 02 Feb in reply to Dimo Link to this post

    Thank you...  this was exactly what I was looking for...

    $("#docResults tbody input:checkbox").prop("checked", this.checked);

     

    Everything else I had, but this one this eluded me...  Unfortunately I'm not a javascript expert, so trying to determine the class name of CSS tags of nested components to get what I need sometimes eludes me...

    Thank you again.

Back to Top