PDA

View Full Version : How to display value in combox of editor grid panel



Komal Vaswani
8 Mar 2011, 3:19 AM
Hi,
how to display the selected content from another window into combo box at the place of empty text and the combobox is defined into editor grid panel.
<code>
grid = new Ext.grid.EditorGridPanel({
name : 'grid',
id : 'grid',
renderTo : JournalForm,
sm: cb_select,
frame : true,
enableColumnHide: false,
autoHeight : true,
width : 1000,
store : tempUserStore,
//buttons:[add,save],
columns : [{
name : 'entryno',
header : "Entry No",
dataIndex : 'entryno',
editor : entryno,
width : 50


}, {

header : "Account Description",
dataIndex : 'accdesc',
editor : accdesc,

width : 200
}
//combobox store
accdesc = new Ext.form.ComboBox({
triggerAction : 'all',
name : 'accdesc',
id:'accdesc',
mode : 'local',
store : ReportingPeriods,
displayField : 'element',
valueField : 'element'

//reader
var reader= new Ext.data.JsonReader({
totalProperty: 'total',
root:'data',
idProperty:'id',
fields:[
{name: 'accdesc', mapping: 'accdesc'}

]
});

});

brittongr
8 Mar 2011, 1:09 PM
Do you want to get the string from another window? which window a extjs window or ?? if is a extjs window and if the text is in a TextField then after closing the window maybe you could set the text like comboBoxEditor.emptyText = 'textreadfromsomewhere'; (not tested);... if this doesn't work please reply...

Komal Vaswani
8 Mar 2011, 9:24 PM
Please explain how to merge your code into my code.

brittongr
8 Mar 2011, 10:30 PM
Please explain how to merge your code into my code.
Ok, i will explain you by the code below, but when i was testing it i realize that you wont be able to that because when the cell is clicked to edit the combo box this get the focus an erase the empty text (almost you can see it), so what you should do is add a renderer to that column and render that text when there is no selected item or the same thing when the value for that cell is null.

The code in red correspond to my previous comment and the blue one to this comment.



var win = null;
var textField = null;

var comboBox = new Ext.form.ComboBox(
{
store: new Ext.data.ArrayStore(
{
data: [[null, null], [1, 'Type 1'], [2, 'Type 3']],
fields: ['value', 'display']
}),
valueField: 'value',
displayField: 'display',
mode: 'local',
triggerAction: 'all',
value: null
});

// create the Grid
var grid = new Ext.grid.EditorGridPanel(
{
store: store,
columns: [
{
id: 'company',
header: 'Company',
width: 160,
sortable: true,
dataIndex: 'company'
},
{
header: 'Company Type',
dataIndex: 'companyType',
editor: comboBox,
renderer: function(v)
{
if(v != null && v.length > 0)
return v;
else
return comboBox.emptyText;
}
}],
stripeRows: true,
height: 350,
width: 600,
title: 'Array Grid',
tbar: [
{
text: 'Show Window',
handler: function(){
if (!win)
{
textField = new Ext.form.TextField(
{
fieldLabel: 'String that will be the empty text'
});

win = new Ext.Window(
{
title: 'Window',
closeAction: 'hide',
width: 300,
height: 200,
items: [
{
layout: 'form',
items: [textField]
}],
buttons: [
{
text: 'Close',
handler: function(){
comboBox.emptyText = textField.getValue();
grid.getView().refresh();
win.close();
}
}]
});
}

win.show();
}
}]
});


I saw that you are passing a cb_select variable to sm config option (Is that a RowSelectionModel instance?? if not it should be)

Hope it helps!

Komal Vaswani
8 Mar 2011, 11:06 PM
Thanks :)

Komal Vaswani
21 Mar 2011, 10:14 PM
how to get all empty text value of combobox of each row in editor gird panel.
for eg: we have 4 rows in editor grid panel and 1 combobox in each row so how to get empty text value's of combobox of each row using rendrer.

Anup Rana
24 Mar 2011, 12:47 AM
i got values in combobox emptytext but now if i m changing in any component of grid it will replace the combobox value with the value in last combobox. it is becouse of rendrer.please explain if any solution.please reply it's urgent

Anup Rana
24 Mar 2011, 1:16 AM
i got values in combobox emptytext but now if i m changing in any component of grid it will replace the combobox value with the value in last combobox. it is becouse of rendrer.please explain if any solution.please reply it's urgent