PDA

View Full Version : Problem with RowEditor + GridPanel + XmlReader/XmlWriter



borillo
13 Jan 2011, 6:18 AM
Ext version tested:


Ext 3.3.1

Adapter used:


ext

css used:


only default ext-all.css

Browser versions tested against:


FF3 3.6.13 (firebug 1.6.1 installed)

Operating System:


Ubuntu 10.04

Description:


When we try to add a new row in the grid with the RowEditor plugin, the row remains dirty everytime.

Test Case:

Code:




<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<link rel="stylesheet" type="text/css" href="http://devel.uji.es/resources/js/ext-3.3.0/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="http://devel.uji.es/resources/js/ext-3.3.0/examples/view/chooser.css" />
<link rel="stylesheet" type="text/css" href="http://devel.uji.es/resources/js/ext-3.3.0/examples/ux/css/RowEditor.css" />

<script type="text/javascript" src="http://devel.uji.es/resources/js/ext-3.3.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="http://devel.uji.es/resources/js/ext-3.3.0/ext-all-debug.js"></script>
<script type="text/javascript" src="http://devel.uji.es/resources/js/ext-3.3.0/examples/ux/RowEditor.js"></script>

<script type="text/javascript">
Ext.BLANK_IMAGE_URL = 'http://devel.uji.es/resources/js/ext-3.3.0/resources/images/default/s.gif';

function generalErrorHandler(proxy, type, action, options, res)
{
try
{
Ext.Msg.alert("Error", res.responseXML.documentElement.getElementsByTagName("message")[0].firstChild.nodeValue);
}
catch (e)
{
if (res.status >= 400)
Ext.Msg.alert("Error", "Mal");
}
}

Ext.onReady( function() {
Ext.QuickTips.init();

var storeModelObject = new Ext.data.Store( {
url : '/test/rest/data',
restful: true,
reader : new Ext.data.XmlReader( {
record : 'dato',
id : 'id',
totalRecords : '@total'
}, [ 'id', 'nombre' ]),
writer : new Ext.data.XmlWriter({
writeAllFields : true,
xmlEncoding: "utf-8"
})
});

storeModelObject.on('exception', generalErrorHandler);


var editorModelObject = new Ext.ux.grid.RowEditor({
saveText : "Guardar",
cancelText : "Cancelar"
});


var actionAddModel = new Ext.Action({
text: "Add",
iconCls: 'icon-plus',
handler: function (button, event)
{
var u = new gridModelObject.store.recordType
({
id: '',
nombre : ''
});
editorModelObject.stopEditing();
gridModelObject.store.insert(0, u);
editorModelObject.startEditing(0);
}
});

var gridModelObject = new Ext.grid.GridPanel
({
title: "test",
store : storeModelObject,
plugins: [ editorModelObject ],
flex: 1,
viewConfig :
{
forceFit : true
},
colModel : new Ext.grid.ColumnModel
({
defaults :
{
sortable : true
},
columns : [
{
header : "id",
dataIndex : 'id'
}, {
header : "nombre",
dataIndex : 'nombre',
editor: new Ext.form.TextField({})
}]
}),
tbar: [ new Ext.Button(actionAddModel) ]
});

var mainWindow = new Ext.Viewport
({
flex : 1,
labelWidth : 100,
labelAlign : 'left',
layout : 'vbox',
autoScroll : true,
frame : true,
layoutConfig :
{
align : 'stretch'
},
items :
[gridModelObject]
});

storeModelObject.load();
});
</script>
</head>
<body>
</body>
</html>
Steps to reproduce the problem:

None

The result that was expected:

None

The result that occurs instead:

None

Screenshot or Video:

None

Debugging already done:

Firebug http debug
=======================

Fill grid request:

Host: localhost:9001
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.04 (lucid) Firefox/3.6.13
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,es-es;q=0.8,en;q=0.5,es;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: UTF-8,*
Keep-Alive: 115
Connection: keep-alive
X-Requested-With: XMLHttpRequest
Referer: http://localhost:9001/test/
Cookie: JSESSIONID=1oo0e7kwwtlg1

Fill grid response:

Content-Type: application/xhtml+xml
Content-Length: 118
Server: Jetty(6.1.22)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><datoes><dato><id>1</id><nombre>Dato 1</nombre></dato></datoes>

Create record request:

Host: localhost:9001
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.04 (lucid) Firefox/3.6.13
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,es-es;q=0.8,en;q=0.5,es;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: UTF-8,*
Keep-Alive: 115
Connection: keep-alive
Content-Type: text/xml; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: http://localhost:9001/test/
Content-Length: 68
Cookie: JSESSIONID=1oo0e7kwwtlg1
Pragma: no-cache
Cache-Control: no-cache

<?xml version="1.0" encoding="utf-8"?><dato><nombre></nombre></dato>

Create record response:

Server: Jetty(6.1.22)

Save with RowEditor plugin request:

Host: localhost:9001
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.04 (lucid) Firefox/3.6.13
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,es-es;q=0.8,en;q=0.5,es;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: UTF-8,*
Keep-Alive: 115
Connection: keep-alive
Content-Type: text/xml; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: http://localhost:9001/test/
Content-Length: 75
Cookie: JSESSIONID=1oo0e7kwwtlg1
Pragma: no-cache
Cache-Control: no-cache

<?xml version="1.0" encoding="utf-8"?><dato><nombre>dafadfa</nombre></dato>

Save with RowEditor plugin response:

Content-Type: application/xhtml+xml
Content-Length: 102
Server: Jetty(6.1.22)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><dato><id>2</id><nombre>dafadfa</nombre></dato>

Possible fix:
not provided

borillo
14 Jan 2011, 12:01 AM
This is working fine in ExtJS 3.2.1

Condor
14 Jan 2011, 12:35 AM
1. Use record:'/' (the record selector locates elements inside the <dato> XML root element, so record:'dato' won't find anything).

2. Do you really want to save your record while the 'nombre' hasn't been filled yet? I would define the 'normre' field with allowBlank:false.