मुझे यकीन नहीं है कि अगर मैं आपको सही मिला तो मुझे पूरा यकीन नहीं है। यदि ऐसा है तो आपको इसके लिए एक रेंडरर की आवश्यकता होगी। मुझे लगता है कि स्नैप किए गए कोड के नीचे उदाहरण आपको दिखाएगा यदि आप इस तरह के मामले का अर्थ हैं।
// the renderer. You should define it within a namespace
var comboBoxRenderer = function(combo) {
return function(value) {
var idx = combo.store.find(combo.valueField, value);
var rec = combo.store.getAt(idx);
return (rec === null ? '' : rec.get(combo.displayField));
};
}
// the edit combo
var combo = new Ext.form.ComboBox({
store: store,
valueField: "value",
displayField: "text"
});
दोनों (cellEditing + rowEditing) के लिए इस पूर्ण काम कर उदाहरण देखें JSFiddle()
यहाँ पूरा कोड
Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone', 'id'],
data:{'items':[
{"name":"Lisa", "email":"[email protected]om", "phone":"555-111-1224","id": 0},
{"name":"Bart", "email":"[email protected]", "phone":"555-222-1234","id": 1},
{"name":"Homer", "email":"[email protected]", "phone":"555-222-1244","id": 2},
{"name":"Marge", "email":"[email protected]", "phone":"555-222-1254","id": 3}
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
// the combo store
var store = new Ext.data.SimpleStore({
fields: [ "value", "text" ],
data: [
[ 0, "Option 0" ],
[ 1, "Option 1" ],
[ 2, "Option 2" ],
[ 3, "Option 3" ]
]
});
// the renderer. You should define it within a namespace
var comboBoxRenderer = function(combo) {
return function(value) {
var idx = combo.store.find(combo.valueField, value);
var rec = combo.store.getAt(idx);
return (rec === null ? '' : rec.get(combo.displayField));
};
}
// the edit combo
var combo = new Ext.form.ComboBox({
store: store,
valueField: "value",
displayField: "text"
});
// demogrid
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{header: 'Name', dataIndex: 'name', editor: 'textfield'},
{header: 'Email', dataIndex: 'email', flex:1,
editor: {
xtype: 'textfield',
allowBlank: false
}
},
{header: 'Phone', dataIndex: 'phone'},
{header: 'id', dataIndex: 'id', editor: combo, renderer: comboBoxRenderer(combo)}
],
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
height: 200,
width: 400,
renderTo: 'cell'
});
// demogrid
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{header: 'Name', dataIndex: 'name', editor: 'textfield'},
{header: 'Email', dataIndex: 'email', flex:1,
editor: {
xtype: 'textfield',
allowBlank: false
}
},
{header: 'Phone', dataIndex: 'phone'},
{header: 'id', dataIndex: 'id', editor: combo, renderer: comboBoxRenderer(combo)}
],
selType: 'rowmodel',
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit: 1
})
],
height: 200,
width: 400,
renderTo: 'row'
});
एचटीएमएल है
<div id="cell"></div>
<div id="row"></div>
मुझे यहां कुछ याद आना चाहिए। मुझे मिल रहा है: टाइप एरर: आरई अनिर्धारित है वापसी (आरईसी === शून्य? '': Rec.get (combo.displayField)); मैं पंक्ति संपादन प्लगइन btw का उपयोग कर रहा हूँ। पता नहीं है कि इससे कोई फर्क पड़ता है? –
@DinandDerksen अच्छा, नहीं। इससे कोई मतभेद नहीं बनना चाहिए। JSFiddle वर्तमान में अनुपलब्ध है इसलिए मैं एक पंक्ति संपादन प्लगइन के साथ एक उदाहरण प्रदान करने में सक्षम नहीं हूँ। लाइन 'rec === null?' को 'rec' में बदलने का प्रयास करें और ध्यान दें कि बॉक्सरेंडर को संपादकीय द्वारा उपयोग किए गए कॉम्बो के उदाहरण को जानना चाहिए। – sra
@DinandDerksen मेरा संपादन देखें। – sra