EasyUI Forum
November 04, 2025, 04:25:48 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: edatagrid and updateURL  (Read 12774 times)
rezzonico
Full Member
***
Posts: 186


View Profile
« on: May 14, 2014, 07:57:13 AM »

Hi Sworthy,

may I ask you to verify if this is a bug or my error ?

I have modified the example with edatagrid found here:
http://www.jeasyui.com/extension/edatagrid.php

The only modification is in order to work with a database and not a json-file.
To this purpose I have added saveUrl and updateUrl (see code below).

The problem:
If I add a new row, "saveUrl" is fired. This is ok.
But if the next action is to modify the last added record, "saveUrl" is fired again (instead of "updateUrl").
If I modify another record (not the last) all is ok.

Thanks a lot if you can confirm this.

Regards
Miche

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jQuery EasyUI</title>
<link rel="stylesheet" type="text/css" href="easyui.css">
<link rel="stylesheet" type="text/css" href="icon.css">
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="jquery.easyui.min.js"></script>
<script type="text/javascript" src="jquery.edatagrid.js"></script>
<script type="text/javascript">
$(function(){
$('#tt').edatagrid({
                           idField: 'itemid',
                           url: 'db.cgi?action=List',
                           saveUrl: 'db.cgi?action=Save',
                           updateUrl: 'db.cgi?action=Update'
});
});
</script>
</head>
<body>
<h1>Editable DataGrid</h1>
<div style="margin-bottom:10px">
<a href="#" onclick="javascript:$('#tt').edatagrid('addRow')">AddRow</a>
<a href="#" onclick="javascript:$('#tt').edatagrid('saveRow')">SaveRow</a>
<a href="#" onclick="javascript:$('#tt').edatagrid('cancelRow')">CancelRow</a>
<a href="#" onclick="javascript:$('#tt').edatagrid('destroyRow')">destroyRow</a>
</div>
<table id="tt" style="width:600px;height:200px"
title="Editable DataGrid",
singleSelect="true">
<thead>
<tr>
<th field="itemid" width="100" editor="{type:'validatebox',options:{required:true}}">Item ID</th>
<th field="productid" width="100" editor="text">Product ID</th>
<th field="listprice" width="100" align="right" editor="{type:'numberbox',options:{precision:1}}">List Price</th>
<th field="unitcost" width="100" align="right" editor="numberbox">Unit Cost</th>
<th field="attr1" width="150" editor="text">Attribute</th>
</tr>
</thead>
</table>
</body>
</html>
« Last Edit: May 14, 2014, 08:07:02 AM by rezzonico » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 14, 2014, 08:21:02 AM »

Be sure to return the added row data from your 'saveUrl' action. Please refer to this tutorial http://www.jeasyui.com/tutorial/app/crud2.php.
Logged
rezzonico
Full Member
***
Posts: 186


View Profile
« Reply #2 on: May 15, 2014, 12:59:32 AM »

Hi stworthy,

you are right ... I didn't return the added row.
Now all works correctly.

I just have a queston about the returned data.
In the program save_user.php it seems me that it is sufficient the return the "id" (mysql_insert_id) and not all the fields.

Do you see a problem if I return only the "id" and not all the fields ?

Thanks a lot for your help.
Miche
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!