Column with checkbox

5 posts, 1 answers
  1. Hugo
    Hugo avatar
    9 posts
    Member since:
    Jul 2012

    Posted 07 Aug 2012 Link to this post

    Hi,

    I'm using the kendo grid control and I have a column that is a checkbox.  It's there a way to catch the event when the user check or uncheck the checkbox for a row ?

    Regards

  2. Bruno Larose
    Bruno Larose avatar
    2 posts
    Member since:
    Jun 2012

    Posted 09 Aug 2012 Link to this post

    Please can you send a sample project?

    thanks

  3. Hugo
    Hugo avatar
    9 posts
    Member since:
    Jul 2012

    Posted 20 Aug 2012 Link to this post

    Yes sure so here it's my view (my project is in VS with MVC).

        <div id='containerGrid' class='grid_12'>
            <div class='grid_3'>&nbsp</div>
            <div id='gridKendo' class='grid_8'>
                
            </div>
        </div>

    <script id="rowTemplate" type="text/x-kendo-tmpl">
        <tr>
            <td>
                <a href="/User/UserDetails?Username=${Username}">${Username}</a>            
            </td>
            <td>
                ${ Email }
            </td>
            <td> 
                #if(ActiveUser){#
                    <input type="checkbox" checked="checked" />
                #}else{#
                    <input type="checkbox" />
                #}#
                       
            </td>
        </tr>
    </script>


    Here my javascript related to the kendo.

            $("#gridKendo").kendoGrid({
                dataSource: {
                    data: data,
                    pageSize: 10
                },
                groupable: false,
                sortable: false,
                selectable: "row",
                filterable: true,
                sortable: true,
                resizable: true,
                reorderable: true,
                pageable: {
                    refresh: false,
                    pageSizes: true
                },
                rowTemplate: kendo.template($("#rowTemplate").html())
            });

    Here I added a screenshot what look like the grid.

    So my goal is when the user click the checkbox in a row to catch this event, know the row selected.  

    Thank you

  4. Answer
    Shane
    Shane avatar
    5 posts
    Member since:
    Feb 2012

    Posted 27 Aug 2012 Link to this post

    Add an onclick to the input type and then find the parent TR element using Javascript.  

    #if(ActiveUser){#
         <input type="checkbox" checked="checked" onclick="DoSomething(this);" />
    #}else{#
         <input type="checkbox" onclick="DoSomething(this);"
    /> #}#


  5. Hugo
    Hugo avatar
    9 posts
    Member since:
    Jul 2012

    Posted 28 Aug 2012 Link to this post

    Thank you 

Back to Top