EasyUI Forum
September 13, 2025, 04:15:52 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Saving a datagrid-subgrid row by calling onClick event  (Read 16847 times)
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« on: February 18, 2015, 10:05:39 AM »

I have defined a column of a subgrid to display Save button as follows :

Code:
{field:'action',title:'Save',width:40,align:'center',
formatter:function(value,row,index){
if(row.editing) {
return '<a href="javascript:void(0)" onclick="saverow()"><img src="images/cross.jpg" /></a> ';
        }
else {
return '<a href="javascript:void(0)" onclick=""><img src="images/checkmark.png" /></a> ';
}
}

Now I want to save the current selected row by calling saverow() function under onClick event, where the problem is I have to pass the current row as parameter to the saverow() function so that I can call a PHP file to save the data in table, but I am unable to send the current row as parameter to the saverow() function. Any body please help me.

Calling of PHP file in saverow() function what I required is as follows:

Code:
$.get("rating.skUpdate.php?yr="+yr+"&tno="+row.tno+"&skname="+encodeURIComponent(row.skname)+"&mra="+row.mrating_ass+"&trgdate="+row.trgdate+"&remarks="+encodeURIComponent(row.remarks)+"&final=Y");

It requires the current row data which is not available in saverow() function. If I call like as onClick = "saverow(row)", it does not work.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2298


View Profile Email
« Reply #1 on: February 18, 2015, 04:59:05 PM »

Here is the example shows how to pass the 'saverow' function.
http://www.jeasyui.com/tutorial/datagrid/datagrid12.php
Logged
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« Reply #2 on: February 19, 2015, 09:26:53 AM »

Thanks for your suggestion. I have already checked the said example. But in my case the case is totally different. First of all in my case this is not inline row editing, it is one step further, in line individual cell editing, where I have added a new method onClickCell for individual datagrid cell. Secondly here in my project the said datagrid is a subgrid acting as detailview of another grid. So the updateRow method of datagrid cannot be used to save data as used in your said example. Moreover for my case a call backend PHP is required to save detail row data in the underlying database table. So only way to pass the current/selected row to the savedata() function. Only problem is I cannot reference how the current selected row can be determined from an external function like savedata(). Following code I have used to define datagrid as well as subgrid as detail view, now please help to by suggesting a way to reference the current selected row in the subgrid.

Code:
$('#dg1').datagrid({
view: detailview,
detailFormatter:function(index,row){
return '<div style="padding:2px"><table class="ddv" ></table></div>';
},
onExpandRow: function(index,row){

var yr = $('#year').combobox('getValue');
var g = $('#cg').combogrid('grid');
var s = g.datagrid('getSelected');
var j = encodeURIComponent($('#jobpos').combobox('getValue'));

var ddv = $(this).datagrid('getRowDetail',index).find('table.ddv');

ddv.datagrid({
idField: 'Id',
method: 'get',
url:'rating.getSkills.php?yr='+yr+'&secode2='+s.secode2+'&jobpos='+j+'&tno='+row.tno,
onClickCell: onClickCell,

Here #dg1 is main grid and var ddv contains the subgrid. I want to reference the current selected row in ddv subgrid so that the current row data can be sent to the backend PHP file using a get/post call.
Logged
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« Reply #3 on: February 20, 2015, 09:26:57 AM »

I have currently implemented Saving of current row by adding onAfterEdit method as follows:

Code:
				        onAfterEdit:function(index,row){
row.editing = false;
$(this).datagrid('updateRow',{index:index, row:{}});

$.get("rating.skUpdate.php?yr="+yr+"&tno="+row.tno+"&skname="+encodeURIComponent(row.skname)+"&mra="+row.mrating_ass+"&trgdate="+row.trgdate+"&remarks="+encodeURIComponent(row.remarks)+"&final=Y");
}

Now what I want just to call this routine by pressing the Save button, i.e., by calling savedata() in onClick method of Save button. Please anybody help me.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!