EasyUI Forum

General Category => General Discussion => Topic started by: dewan on November 17, 2018, 07:37:55 AM



Title: Datagrid add a action button
Post by: dewan on November 17, 2018, 07:37:55 AM
Hi
how do i add a action button in datagrid . I would like to add a view action button when user click on it want to load the detail page.

Thank you


Title: Re: Datagrid add a action button
Post by: stworthy on November 17, 2018, 08:16:08 PM
Please look at this page https://www.jeasyui.com/tutorial/datagrid/datagrid12.php


Title: Re: Datagrid add a action button
Post by: dewan on November 22, 2018, 04:23:17 AM
thank you


Title: Re: Datagrid add a action button
Post by: officecode on December 05, 2018, 05:27:01 AM
Please look at this page https://www.jeasyui.com/tutorial/datagrid/datagrid12.php

In this example, how do I get the data row of index?
I know that I can use the ‘selectRow‘ method and then ‘getSelected’ to get it. But there is a problem here. If multiple rows have been selected in the datagrid, the ‘getSelected’ method does not necessarily get the row that is needed.

Code:

function getRowIndex(target){
    var tr = $(target).closest('tr.datagrid-row');
    return parseInt(tr.attr('datagrid-row-index'));
}
function editrow(target){
    var index = getRowIndex(target);
    $('#tt').datagrid('beginEdit', index);

   //How to get the data row of this index?
}



Title: Re: Datagrid add a action button
Post by: officecode on December 05, 2018, 08:29:51 PM
Looked at the elements carefully and solved:

tr.find('td[field="id"]').text();