-
12 Aug 2011 1:08 AM #11
Hey Joel,
Indeed, learning comes from doing. I've been able to achieve what I wanted thanks to your help.
.
David
-
12 Aug 2011 5:20 AM #12
Hey Joel,
One more question on your code. How did you know that there was this event listener on the grid
select: function(view, record, rowIndex , colIndex , listeners) {
as I've looked at http://docs.sencha.com/ext-js/4-0/#/api/Ext.grid.Panel and it isn't mentioned anywhere. I really want to know how to help myself rather than asking but in this case I'd never have worked that out all by myself.
-
12 Aug 2011 5:32 AM #13
this is what I mean about "understand" Ext

A. those guys don't have all the time in the world to give you a FREE service.
B. You have to start reading he source code. It really makes a good bed time reading (I am not kidding. I read the source code bit by bit on my iPad before going to bed ... yes I know its sad)
C. Read their blog and everything you could get hold of on this website.
if you have read the grid faq. you should come across this
So after you create your grid. You could do ...PHP Code:
function captureEvents(observable) {
try {
Ext.util.Observable.capture(observable, function(eventName) {
try {
console.log(eventName);
} catch(e) {
throw e;
}
}, this);
} catch(e) {
throw e;
}
}
This little handy tool will allow you to look inside the entire event chain with every one of the Extjs object.PHP Code:var grid = .... stuff to do with grid etc etc etc ....
captureEvents(grid)
Now there is master card but there is also something call - priceless
I accept paypal too :p
-
12 Aug 2011 5:58 AM #14
I saw your other post about firing an event.
Good luck with that. I abandon that idea very early on due to the time delay (no idea why).
One thing you could use which is from the same until captureEvents (just search the doc for the terms "fire event")
then your grids set up aPHP Code:Ext.util.Observable.fireEvent('mycustomeventnamewhateverIwanttocallit' , grids);
Do try that and might be useful.PHP Code:'mycustomeventnamewhateverIwanttocallit': function() {
// do stuff - you might want to pass parameter along with that as well.
}
-
12 Aug 2011 6:08 AM #15
I've found the answer I believe. The events are http://docs.sencha.com/ext-js/4-0/#/...l-event-select
-
16 Aug 2011 2:36 AM #16
UPDATE
UPDATE
After a lot of user testing and I found a major bug in my approach. My thinking was right but I hit a limitation from the lib.
Go back a bit - when I try to catch the event - I hit the same problem - how do I identify where am I ? Because Column A init the event then Column B catch the event simple right?
Very wrong - should be Column 1-A init the event then Column 1-B to catch the event. See the different (there could be column 100000039482038432-A to 100000039482038432-B ...) so catching event is out of the question.
Using "select" or "cellclick" event did get me the record , x , y and z and everything else - but the problem is I can only pass this to the underlying element - once! On my other post. I found if I init the listener on the fly - that listener stay. If I try to removeListeners then add it again. It doesn't work.
So went back to the drawing board. Rethink - what was the question.
A. I want to be able to validate one field against another field on the same row but different column.
B. Its a moving target because I do not know how many rows will there be.
C. but there is a constant - the relationship only need to exist in the row level.
So I try again and test out all the events available to a combo box. Then I found one that is good to catch - focus. (render will only be call once then during the life time of the grid - the combo box render event will not be call again - if I need to refresh something every time that is not a good place to start).
So when the combo is in focus - all I need to do is to find out which row am I in.
Try a lot findParent findParentNode etc but no luck. I use jQuery with Extjs - so I go the underlying el.id then try
and it actually gave me the grid panel body ... strange. Is it supposed to be inside a cell? Then a look at the underlying html - the combo box (or any editor) is actually place outside of the grid! So that route is close. Since the position is no where near the grid cell.PHP Code:
$('#'+combo.el.id).parent();
Then it hits me - the answer is easier than I thought ... months of work (seriously I have been working on this feature for 2 months now!)
Think outside the box - this is exactly what it takes to solve this problem.
When the focus event fire - all I have to do is to find out which row is currently get selected from the grid itself!
Do try this at homePHP Code:
combo.listeners = {
focus: function(combo , opt) {
var selected = grid.getView().getSelectionModel();
var record = selected.store.getAt(selected.position.row);
console.log(record); // this is all I need!!!
// then I just need to find out which combo box I am using -
// then validate against the record!
// and enable disable - reload what not for all I want with this combobox!
}
}
Hope this help some of you still stuck with this problem.
One thing I take away from this is - you have to understand the question before you can find the answer. Until next time.
-
16 Aug 2011 3:09 AM #17
Hey Joel,
Thank you for your update. It was very useful and will help save me so much time.
David


Reply With Quote