Anonymous
Jquery Easy UI получает доступ к данным в строках индивидуально для выполнения пользовательских вызовов ajax.
Сообщение
Anonymous » 27 ноя 2025, 01:00
В демонстрационном файле datagrid2.html jquery-easyui-1.2.6 я пытаюсь получить доступ к данным в строках через javascript, чтобы использовать его для создания URL-адреса ajax для сохранения изменений пользовательского интерфейса на стороне сервера.
Весь HTML-код выглядит следующим образом:
Код: Выделить всё
Editable DataGrid - jQuery EasyUI Demo
var products = [
{productid:'FI-SW-01',name:'Koi'},
{productid:'K9-DL-01',name:'Dalmation'},
{productid:'RP-SN-01',name:'Rattlesnake'},
{productid:'RP-LI-02',name:'Iguana'},
{productid:'FL-DSH-01',name:'Manx'},
{productid:'FL-DLH-02',name:'Persian'},
{productid:'AV-CB-01',name:'Amazon Parrot'}
];
function productFormatter(value){
for(var i=0; i
if (products[i].productid == value) return products[i].name;
}
return value;
}
$(function(){
var lastIndex;
$('#tt').datagrid({
toolbar:[{
text:'Add New',
iconCls:'icon-add',
handler:function(){
$('#tt').datagrid('endEdit', lastIndex);
$('#tt').datagrid('appendRow',{
itemid:'',
productid:'',
listprice:'',
unitprice:'',
attr1:'',
status:'P'
});
lastIndex = $('#tt').datagrid('getRows').length-1;
$('#tt').datagrid('selectRow', lastIndex);
$('#tt').datagrid('beginEdit', lastIndex);
}
},'-',{
text:'Delete',
iconCls:'icon-remove',
handler:function(){
var row = $('#tt').datagrid('getSelected');
if (row){
var index = $('#tt').datagrid('getRowIndex', row);
$('#tt').datagrid('deleteRow', index);
}
}
},'-',{
text:'Edit Save',
iconCls:'icon-save',
handler:function(){
$('#tt').datagrid('acceptChanges');
}
},'-',{
text:'Undo',
iconCls:'icon-undo',
handler:function(){
$('#tt').datagrid('rejectChanges');
}
},'-',{
text:'GetChanges',
iconCls:'icon-search',
handler:function(){
var rows = $('#tt').datagrid('getChanges');
alert('changed rows: ' + rows.length + ' lines');
}
}],
onBeforeLoad:function(){
$(this).datagrid('rejectChanges');
},
onClickRow:function(rowIndex){
if (lastIndex != rowIndex){
$('#tt').datagrid('endEdit', lastIndex);
$('#tt').datagrid('beginEdit', rowIndex);
}
lastIndex = rowIndex;
}
});
});
Editable DataGrid
Click the row to start editing.
Item ID
Product
List Price
Unit Cost
Attribute
Status
Дайте мне знать, чтобы получить дополнительные разъяснения
Подробнее здесь:
https://stackoverflow.com/questions/116 ... -ajax-call
1764194440
Anonymous
В демонстрационном файле datagrid2.html jquery-easyui-1.2.6 я пытаюсь получить доступ к данным в строках через javascript, чтобы использовать его для создания URL-адреса ajax для сохранения изменений пользовательского интерфейса на стороне сервера. Весь HTML-код выглядит следующим образом: [code] Editable DataGrid - jQuery EasyUI Demo var products = [ {productid:'FI-SW-01',name:'Koi'}, {productid:'K9-DL-01',name:'Dalmation'}, {productid:'RP-SN-01',name:'Rattlesnake'}, {productid:'RP-LI-02',name:'Iguana'}, {productid:'FL-DSH-01',name:'Manx'}, {productid:'FL-DLH-02',name:'Persian'}, {productid:'AV-CB-01',name:'Amazon Parrot'} ]; function productFormatter(value){ for(var i=0; i if (products[i].productid == value) return products[i].name; } return value; } $(function(){ var lastIndex; $('#tt').datagrid({ toolbar:[{ text:'Add New', iconCls:'icon-add', handler:function(){ $('#tt').datagrid('endEdit', lastIndex); $('#tt').datagrid('appendRow',{ itemid:'', productid:'', listprice:'', unitprice:'', attr1:'', status:'P' }); lastIndex = $('#tt').datagrid('getRows').length-1; $('#tt').datagrid('selectRow', lastIndex); $('#tt').datagrid('beginEdit', lastIndex); } },'-',{ text:'Delete', iconCls:'icon-remove', handler:function(){ var row = $('#tt').datagrid('getSelected'); if (row){ var index = $('#tt').datagrid('getRowIndex', row); $('#tt').datagrid('deleteRow', index); } } },'-',{ text:'Edit Save', iconCls:'icon-save', handler:function(){ $('#tt').datagrid('acceptChanges'); } },'-',{ text:'Undo', iconCls:'icon-undo', handler:function(){ $('#tt').datagrid('rejectChanges'); } },'-',{ text:'GetChanges', iconCls:'icon-search', handler:function(){ var rows = $('#tt').datagrid('getChanges'); alert('changed rows: ' + rows.length + ' lines'); } }], onBeforeLoad:function(){ $(this).datagrid('rejectChanges'); }, onClickRow:function(rowIndex){ if (lastIndex != rowIndex){ $('#tt').datagrid('endEdit', lastIndex); $('#tt').datagrid('beginEdit', rowIndex); } lastIndex = rowIndex; } }); }); Editable DataGrid Click the row to start editing. Item ID Product List Price Unit Cost Attribute Status [/code] Дайте мне знать, чтобы получить дополнительные разъяснения Подробнее здесь: [url]https://stackoverflow.com/questions/11664061/jquery-easy-ui-access-the-data-in-the-rows-individually-to-make-custom-ajax-call[/url]