Я использую Smart GWT 2.3.0 в любом браузере.
У меня есть простая сетка только с данными. И когда я создаю новый регистр, он не обновляет мой идентификатор.
Я прочитал об этом часто задаваемые вопросы и думаю, что все правильно .
код источника данных:
DataSource ds = null;
try {
ds = new DataSource();
ds.setDataURL("do");
ds.setController(controller);
DataSourceTextField nombre = new DataSourceTextField("nombre",
"Nombre", 50, true);
DataSourceTextField codigo = new DataSourceTextField("codigo",
"Código", 50, true);
DataSourceTextField id = new DataSourceTextField("id",
"Identificador", 50);
id.setPrimaryKey(Boolean.TRUE);
id.setCanEdit(Boolean.FALSE);
ds.setFields(id, codigo, nombre);
Результат консоли:
16:43:29.808:KPR3:DEBUG:gridEdit:isc_ListGrid_1:showing
Извините, я забыл сказать, что то же самое происходит во вставке, это журнал вставки:
Вот что отправляет мой сервер JSON в качестве ответа на добавление нового регистра:
13:22:09.162:KPR3:DEBUG:gridEdit:isc_ListGrid_0:change detection: newValues: {codigo: "prueba",
nombre: "prueba"}, oldValues: undef
13:22:09.167:KPR3:DEBUG:gridEdit:isc_ListGrid_0:At field: codigo applying validators: [
{type: "isString",
typeCastValidator: true,
_generated: true,
defaultErrorMessage: "Debe ser una Cadena."},
{type: "required",
defaultErrorMessage: undef,
errorMessage: "Campo es obligatorio"}
] to value:prueba
13:22:09.168:KPR3:INFO:gridEdit:isc_ListGrid_0:validateFieldValue, newValue: "prueba", passed validation: true, resultingValue: null
13:22:09.170:KPR3:DEBUG:gridEdit:isc_ListGrid_0:At field: nombre applying validators: [
{type: "isString",
typeCastValidator: true,
_generated: true,
defaultErrorMessage: "Debe ser una Cadena."},
{type: "required",
defaultErrorMessage: undef,
errorMessage: "Campo es obligatorio"}
] to value:prueba
13:22:09.172:KPR3:INFO:gridEdit:isc_ListGrid_0:validateFieldValue, newValue: "prueba", passed validation: true, resultingValue: null
13:22:09.172:KPR3:INFO:gridEdit:isc_ListGrid_0:Saving newValues '{codigo: "prueba",
nombre: "prueba"}'
13:22:10.612:XRP7:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):dataSource data changed firing
13:22:10.612:XRP7:INFO:ResultSet:isc_XDataSource_1:dsResponse for successful operation of type add did not return updated record[s]. Using submitted request data to update ResultSet cache.
13:22:10.612:XRP7:DEBUG:ResultSet:isc_XDataSource_1:Submitted data to be integrated into the cache:[
{codigo: "prueba",
nombre: "prueba"}
]
13:22:10.613:XRP7:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updating cache in place after operationType: add, allMatchingRowsCached true
13:22:10.613:XRP7:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Updating cache: operationType 'add' submitted by 'isc_ListGrid_0',1 rows update data:
[
{codigo: "prueba",
nombre: "prueba"}
]
13:22:10.614:XRP7:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Local filter applied: 3 of 3 records matched filter:{
}
13:22:10.615:XRP7:INFO:ResultSet:isc_XDataSource_1:dsResponse for successful operation of type add did not return updated record[s]. Using submitted request data to update ResultSet cache.
13:22:10.615:XRP7:DEBUG:ResultSet:isc_XDataSource_1:Submitted data to be integrated into the cache:[
{codigo: "prueba",
nombre: "prueba"}
]
13:22:10.627:RDQ9:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(0, 2) satisfied from cache
И это мой ответ на обновление реестра:
input: {
"__requestBody": {
"dataSource": "isc_XDataSource_1",
"operationType": "add",
"data": {
"nombre": "prueba",
"codigo": "prueba"
},
"componentId": "isc_ListGrid_0",
"oldValues": null
},
"inputfields": [
{
"value": "prueba",
"property": "nombre"
},
{
"value": "prueba",
"property": "codigo"
}
],
"__requestFormat": "smartgwt",
"__httpSession": "org.apache.catalina.session.StandardSessionFacade@1c2b15c",
"__http_request": "org.apache.catalina.connector.RequestFacade@18d70a6",
"fields": [
{
"name": "id",
"property": "id"
},
{
"name": "codigo",
"property": "codigo"
},
{
"name": "nombre",
"property": "nombre"
}
]
}
Вы не можете изменить первичный ключ с помощью обновления (как и в SQL). Сделайте удаление, затем добавьте.
{
"id": "1",
"__requestBody": {
"dataSource": "isc_XDataSource_2",
"operationType": "update",
"data": {
"nombre": "prueba2",
"id": "1"
},
"componentId": "isc_ListGrid_0",
"oldValues": {
"id": "1",
"codigo": "prueba",
"nombre": "prueba"
}
},
"inputfields": [
{
"value": "prueba2",
"property": "nombre"
},
{
"value": "1",
"property": "id"
}
],
"__requestFormat": "smartgwt",
"__httpSession": "org.apache.catalina.session.StandardSessionFacade@1c2b15c",
"__http_request": "org.apache.catalina.connector.RequestFacade@1d40d08",
"fields": [
{
"name": "id",
"property": "id"
},
{
"name": "codigo",
"property": "codigo"
},
{
"name": "nombre",
"property": "nombre"
}
]
}