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
}