No more nonsense to say, directly to everyone paste code.
The key code looks like this:
The most recent use of the edit line everything normal///<summary>///initializes the data container///</summary> function Initgrid () {var lastindex; $ ("#grid"). Data Grid ({URL: ', loadmsg: ' In data loading, please later ... ', Border:false, Fitcolumns:true, Remotesort:false, Ondblclickrow:function ( Rowindex,rowdata) {Lastindex=rowindex $ ("#grid"). DataGrid (' EndEdit ', RowIndex); $ ("#grid"). DataGrid (' BeginEdit ',
RowIndex);
var oldordering = rowdata.ordering; $ ("Input.datagrid-editable-input"). Val (oldordering). bind ("Blur", function (evt) {Setorder ($ (this). Val (), Eval (" RowData. "
+actid));
$ ("#grid"). DataGrid (' EndEdit ', lastindex); }. Bind ("KeyPress", function (evt) {if (evt.keycode==13) {Setorder ($ (this). Val (), eval ("RowData.").
+actid));
$ ("#grid"). DataGrid (' EndEdit ', lastindex);
}). focus ();
Lastindex=rowindex;
}, frozencolumns:[[{field: ' CK ', checkbox:true}]], toolbar:[{text: ' Refresh ', iconcls: ' Icon-reload ', handler:function () {
Reload (); }, {text: ' Add ', Iconcls: ' Icon-add ', Handler:add}, {text: ' edit ', iconcls: ' Icon-edit ', Handler:edit}, {text: ' delete ', iconcls: ' Icon-cut ', Handler:deL}, {text: ' Clear ', iconcls: ' Icon-undo ', Handler:function () {$ ("#grid"). DataGrid ("Clearselections");}], columns:[[{ Field:actid,title: ' Serial number ', Width:17,align: ' Center ', sortable:true,sorter:sortid}, {field: ' JobName ', title: ' Recruitment position ', Width:40,align: ' Center ', sortable:true}, {field: ' Jobkind ', title: ' Type ', width:60,align: ' Center ', sortable:true}, { Field: ' Requirenum ', title: ' Number ', Width:12,align: ' Center ', sortable:true}, {field: ' email ', title: ' Mailbox ', Width:34,align: ' Center ', sortable:true}, {field: ' Ordering ', title: ' Sort ', width:10,align: ' Center ', Sortable:true,editor:{type: ' Numberbox '}, {field: ' Lasttime ', title: ' Due Time ', Width:40,align: ' Center ', sortable:true}, {field: ' act ', title: ' Operation ',
Width:40,align: ' Center ', Formatter:act}]}); }
Previous use
<summary>///Initialization Data container///</summary> function Initgrid () {var lastindex; $ ("#grid"). DataGrid ({url: ', Loadmsg: ' In data loading, please later ... ', Border:false, Fitcolumns:true, Remotesort:false,//double-click changed editable state ondblclickrow:function ( Rowindex,rowdata) {var oldnum = Rowdata.g_num//if (lastindex!=rowindex) {$ ("#grid"). DataGrid (' EndEdit ', rowIndex);
"#grid"). DataGrid (' BeginEdit ', rowIndex);
var num = rowdata.g_num;
$ ("Input.datagrid-editable-input"). Val ("+"); $ ("Input.datagrid-editable-input"). Bind ("Blur", function (evt) {var input = $ (this). val ()? eval ($ (this). Val ()): 0; var
result = Setnum (input,rowdata.id,oldnum);
var item = result.split ("| |");
$ (this). Val (item[1]);
$ ("#grid"). DataGrid (' EndEdit ', lastindex);
}); $ ("Input.datagrid-editable-input"). Bind ("KeyPress", function (evt) {if (evt.keycode==13) {var input = $ (this). Val ()? $ (
This). Val (): 0;
var result = Setnum (input,rowdata.id,oldnum);
var item = result.split ("| |");
$ (this). Val (item[1]);
$ ("#grid"). DataGrid (' EndEdit ', lastindex);
}
}); } lastindEx=rowindex;
}, frozencolumns:[[{field: ' CK ', checkbox:true}]], toolbar:[{text: ' Refresh ', iconcls: ' Icon-reload ', handler:function () {
Reload (); }, {text: ' Add ', Iconcls: ' Icon-add ', Handler:add}, {text: ' edit ', iconcls: ' Icon-edit ', Handler:edit}, {text: ' delete ', iconcls: ' Icon-cut ', Handler:del}, {text: ' select ', iconcls: ' Icon-undo ', Handler:function () {$ (' #grid '). DataGrid ("Clearselections ");}}], columns:[[{field: ' id ', title: ' Serial Number ', Width:40,align: ' Center ', sortable:true,sorter:sortid}, {field: ' G_name ', Title: ' Product Name ', width:40,align: ' Center ', sortable:true}, {field: ' Gt_name ', title: ' Type ', width:40,align: ' Center ', Sortable:true}, {field: ' G_num ', title: ' Inventory ', width:40,align: ' Center ', Sortable:true,editor:{type: ' Numberbox '}}, { Field: ' G_isnew ', title: ' Is it new ', Width:40,align: ' Center ', Sortable:true,formatter:function (val) {return val== ' 1 '? '
Is ': ' No '; }, {field: ' G_ishot ', title: ' Hot Goods ', width:40,align: ' Center ', Sortable:true,formatter:function (val) {return val== ' 1 '? '
Is ': ' No '; }, {field: ' G_status ', title: ' State ', Width:40,align: ' Center ', Sortable:truE,formatter:status}, {field: ' G_addtime ', title: ' Add Time ', Width:40,align: ' Center ', sortable:true}, {field: ' act ', title:
' Operations ', Width:40,align: ' Center ', Formatter:act}]}); ///<summary>///ajax Get Paging data///currpage => Current page number///</summary> function GetData (currpage) {var pageSize = g
Etpagesize ();//15;
var where=$ ("#where"). Val ();
var levels=$ ("#pt"). Val (); $.ajax ({url:url+ '/ajaxdata ', type: ' Post ', DataType: ' Text ', data: ' currpage= ' +currpage+ ' &pagesize= ' +pagesize+ ' " + ' &where= ' +where+ ' &pt= ' +levels, Beforesend:function () {$ ("#grid"). DataGrid ("Loading");}, Success:function (JSON) {$ ("#grid"). DataGrid ("Loaded"); Json=decodeuricomponent (JSON); if (json.length<=20) {$ ("#grid"). DataGrid ("
LoadData ", {total:0,rows:[]});
Return
JSON = eval (' (' +json+ ') ');
$ ("#grid"). DataGrid ("LoadData", JSON);
$ ("#currPage"). Val (currpage);
$ ("#pageCount"). Val (Math.ceil (json.total/pagesize));
$ ("#pageStr"). HTML (SHORTPAGESTR (json.total));
Showpagebar (); }, Error:function (data) {alert (Data.responsetexT);
}
}); ///<summary>///@desc Modify inventory (out of storage)///</summary> function Setnum (count,id,oldnum) {var result = ' error| | '
+oldnum; $.ajax ({url:url+ '/setnum ', type: ' Post ', DataType: ' Text ', data: ' count= ' +count+ ' &sx= ', +id, Async:false: function (data) {result = data}, error:function (data) {result= ' error| | '
+oldnum;
}
});
return result; }
The above is reproduced content, the following for their own validation code:
function _createtable (data) {//$.each transcoding of Chinese characters (data.data, function (i, obj) {var eventName = unescape (obj.eventname); var l
Evelname = unescape (obj.levelname);
Obj.eventname = EventName;
Obj.levelname = LevelName;
}); Data processing var column = [{title: ' id ', field: ' ID ', width:100,align: ' Left '}, {title: ' Level number ', field: ' Levelnum ', width:100,align
: ' Left '}, {title: ' Level name ', field: ' LevelName ', width:100,align: ' Left ', formatter:function (data) {if (data = = ' null ') { Return "";} else{return data;}},editor:{type: ' Text '}}, {title: ' Activity id ', field: ' EventId ', width:60,align: ' Left ', Rowspan:1, Hidden: True}, {title: ' Creator ID ', field: ' Createuid ', width:100,align: ' Left '}, {title: ' Creation Time ', field: ' CreateDate ', width:150,
Align: ' left '}];
var root = Listtodatagrid (data);
var title = "Avatar List";
_getdatagrid ("Eventlisttable", title, ' ID ', column). DataGrid (' LoadData ', root);
function _getdatagrid (ID, atitle, pk, columns) {var el = $ (' # ' + ID + '); if (El.data (' datagridinit ')!== ' finished ') {
var lastindex; El.datagrid ({Columns:[columns],
Title:atitle, width:1000, Nowrap:false, IDFIELD:PK, Rownumbers:true, Striped:true, singleselect:true, collapsible: True, Sortname: ' Levelnum ', Pagination:false, Pagesize:pagesize, SortOrder: ' ASC ', Remotesort:false, IDfield: ' id ', rown Umbers:true, toolbar:[{ID: ' btnmodify ', text: ' Modify ', Iconcls: ' Icon-cut ', Handler:_showdialog (ID)}, '-', {ID: ' Btnremove '
, text: ' Delete ', iconcls: ' Icon-cancel ', Handler:_removeevent (ID)}], Ondblclickcell:function (rowIndex, field, value) {
Lastindex=rowindex;
$ (' # ' +id). DataGrid (' EndEdit ', rowIndex);
$ (' # ' +id). DataGrid (' BeginEdit ', rowIndex);
var oldordering = value; $ ("Input.datagrid-editable-input"). Val (oldordering). bind ("Blur", function (evt) {debugger; var Dataarry = $ (' # ' +id).
DataGrid (' Getselections ');
Eventplayer.setlevelname ($ (this). Val (), dataarry[0].id);
$ (' # ' +id). DataGrid (' EndEdit ', lastindex);
}. Bind ("KeyPress", function (evt) {if (evt.keycode==13) {debugger; var Dataarry = $ (' # ' +id). DataGrid (' Getselections '); Eventplayer.setlevelname ($ (this). Val (), Dataarry[0].id);
$ (' # ' +id). DataGrid (' EndEdit ', lastindex);
}). focus ();
Lastindex=rowindex;
}
});
Register paging Query method var p = $ (' # ' + ID). DataGrid (' Getpager ');
$pagination (p, {onselectpage:function (pagenumber, pageSize1) {geteventplayerdatalist ();}});
El.data (' Datagridinit ', ' finished '); }
The above is a small set to introduce the jquery Easyui DataGrid click on a cell that goes into the edit state focus to save the data, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!