PDA

View Full Version : Row Editor with TriggerField and Menu(on Click)



umit
15 Apr 2010, 10:49 PM
Hi Everyone!

I have a grid with roweditor.
Now i want to have a triggerfield in the cell and when i press on it, i want to have a menu.

Is this possible?
I already tried but i get errors.

The idea is to have something like a datepicker(timepicker)
Code:


//.....roweditor ....columns:.....
{
header: 'WochenTage',
dataIndex: 'WOCHE',
width: 100,
sortable: true,
editor:
new Ext.form.TriggerField({items:
new Ext.menu.Menu({
allowBlank: true,
items:[{xtype:"label",text:"1"},{xtype:"label",text:"2"}]
})})
}
/....

dj
16 Apr 2010, 3:59 AM
You need to override the onTriggerClick function for your TriggerField to do something.
http://www.extjs.com/deploy/dev/docs/?class=Ext.form.TriggerField

In the onTriggerClick function you could open the menu.

But why don't you just use a ComboBox with a local store?

umit
16 Apr 2010, 4:16 AM
Thanks for the reply

I want to have something like a Date picker, when i press the triggerButton, an ext.window shall appear, that is connected to the triggerfield.

So i tried to abuse the menu for this purpose(you can click in the menu that is connected with a bar but if you click somewhere out, the menu closes)

But the triggerbutton won't accept items ...

I dont use a combobox because, its a window(that in the code snipped was just an example)

So the point is, i want to have a triggerfield, and if you click at it, my formWindow should appear(up or bot to the triggerfield) and when i click somewhere else in the screen it shall disappear
Any suggestions`how to make something like that?

dj
16 Apr 2010, 5:55 AM
This should bring you on the right track


{
header: 'WochenTage',
dataIndex: 'WOCHE',
width: 100,
sortable: true,
editor: new Ext.form.TriggerField({
onTriggerClick: function(e) {
if (!this.menu) {
this.menu = new Ext.menu.Menu({
items:[{xtype:"label",text:"1"},{xtype:"label",text:"2"}]
// the items should have event listeners that set the field value accordingly
});
}
// here you would want to sync the items in the menu with the field value (this.getValue())
// before you show the menu -- keep in mind that the menu and its children might not be rendered yet
this.menu.showAt(e.getXY()); // or this.menu.show(this.getEl(), 'tl-bl?');
}
})
}

umit
19 Apr 2010, 12:25 AM
ty dj
That was exactly what I was looking for