Application of embedded dynamic ComboBox in grid in ExtJS _extjs

Source: Internet
Author: User
Tags rowcount
Get ComboBox's data.
Copy Code code as follows:

Combods = new Ext.data.JsonStore ({
URL: ' Test.do ',
Fields: [{
Name: ' ID '
}, {
Name: ' Display '
}]
});

ComboBox definition
The ID in the ComboBox must have, followed by the ComboBox value of the ID.
Copy Code code as follows:

var comboBox = new Ext.form.ComboBox ({
ID: "CB",//Must have
Typeahead:true,
Readonly:true,
Allowblank:false,
Autoscroll:true,
Selectonfocus:true,
Emptytext: ' Please choose ... ',
Store:combods,
Forceselection:true,
TriggerAction: ' All ',
Displayfield: ' Display ',
Valuefield: ' ID '
});

Definition of grid:
Copy Code code as follows:

ds = new Ext.data.Store ({
Baseparams: {
start:0,
Limit:rowcount
},
Proxy:new Ext.data.HttpProxy ({
URL: ' test2.do '
}),
Reader:new Ext.data.JsonReader ({
Root: ' Data ',
Totalproperty: ' TotalCount '
}, [{
Name: "BH"
}, {
Name: "Test"
}]);
});
var cm = new Ext.grid.ColumnModel ([New Ext.grid.RowNumberer (), {
Header: "Number",
Dataindex: "BH"
}, {
Header: "Test",
Dataindex: "Test",
Renderer:renderer,
Editor:combobox
}]);
Grid = new Ext.grid.EditorGridPanel ({
Title: ' Test ',
Ds:ds,
CM:CM,
Clickstoedit:1,
Viewconfig: {
Forcefit:true
},
Bbar:new Ext.pagingtoolbar ({
Pagesize:rowcount,
Store:ds,
Displayinfo:true,
Displaymsg: ' Show {0} to {1} records, altogether {2} ',
Emptymsg: "No Record"
})
});

CM's renderer function
This method is displayed as an ID after resolving combobox modifications
Copy Code code as follows:

function renderer (value, p, r) {
var index = combods.find (ext.getcmp (' CB '). Valuefield, value);
var record = Combods.getat (index);
var displayText = "";
if (record = = null) {
DisplayText = value;
} else {
DisplayText = record.data.display;//Gets the value of the Display field in the recordset in the record
}

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.