2015-09-09 87 views
0

我使用Jqxgrid來顯示我的動態數據,因爲我的最後一列中有每行都有編輯按鈕。我需要點擊編輯按鈕來執行特定的行編輯。如何編輯jqxgrid代碼隱藏的動態行數據

我使用Datatable和smartgridboundfields來顯示jqxgrid中的數據。

我該如何執行此類功能?

string html =「」;

  html += "<a id='sedit'>Edit</a>"; 
      html += "<a id='sdelete' style='margin-left: 10px'>Delete</a>"; 

      dr["Actions"] = html; 

這段代碼的背後是編輯按鈕,我在jqxgrid顯示我的代碼。

回答

0

在這種情況下,你可以使用beginrowedit

$('#sedit').on('click', function() { 
    // here change the 0 for the row index 
    $("#jqxgrid").jqxGrid('beginrowedit', 0); 
}); 

或者begincelledit

$('#sedit').on('click', function() { 
    // here change the 0 for the row index, 
    // and your column datafield instead of "firstname" 
    $("#jqxgrid").jqxGrid('begincelledit', 0, "firstname"); 
}); 

爲了獲得行索引: var rowindex = $('#jqxgrid').jqxGrid('getselectedrowindex');