First, define the Edit button in the Tbar of the grid:
JS Code
Copy Code code as follows:
ID: ' Editdatabutton ',
Text: ' Edit ',
ToolTip: ' Edit ',
Iconcls: ' Edit ',
Handler:function () {Showeditpanel ();}
Define form again:
JS Code
Copy Code code as follows:
var xjjleditform = new Ext.formpanel ({..... Omit the definition in form ...});
Then define the function Showeditpanel that the edit button will call (also define a window that loads the form):
JS Code
Copy Code code as follows:
--Edit the function called by the button (pop-up edit form)
function Showeditpanel ()
{//Direct access to the selected row corresponding to the record
var record = Grid.getselectionmodel (). getselected ()
if (!record) {
Ext.Msg.alert (' Information ', ' Please select the data to be edited ');
Return
}
--Define Edit form
if (!xjjleditwindow)
{
Xjjleditwindow = new Ext.window ({
El: ' Edit_win ',//the div name in the page where the current JS file is placed
Title: ' Edit Record ',
WIDTH:650,
Height:360,
Closable:false,
Closeaction: ' Hide ',
Resizable:false,
Items:xjjleditform//loading edited form in window
});
}
Xjjleditwindow.show (Ext.get (' Editdatabutton '))//Display edit window
[Note] First xjjleditwindow.show (); Again Xjjleditform.getform (). Loadrecord (Currrecordrecord); You can solve the problem of not loading data into form when you click the Edit button the first time after the page load completes.
Xjjleditform.getform (). Loadrecord (record);
The point here is to fill the form with the record in the currently selected grid
}
This allows you to edit the selected data in a new window;