Method of form and grid interaction data (record) in ExtJS _javascript skills

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.