onLoad event for Store

Ask our community for help with v1.x versions of our products.

onLoad event for Store

Postby NisseKnudsenSystecs » Mon Mar 26, 2012 6:04 pm

Hey!

I have a problem, and I see one or two options to solve it, but as usual I want to ask you guys first, because there is normally a easier solution ;)

The situation:

I have a gantt chart 1.x and a few columns in it. ONE of the columns has a renderer which searches an additional DirectStore 'feedStore', and if a record exists it returns <img>PictureA</img> otherwise <img>PictureB</img>.

The problem:

when the gantt chart column is rendered, obviously there feedStore hasn't been loaded. I assume that by the following tests: When adding console.log(feedStore.getTotalCount), I get a long list of ZEROs. The other thing is, that when I debug with breakpoints, I get the desired result (obviously the store has finished loading the data).

So what to do now?

a.) Add 'load' event to the feedStore and make DOM manupilation for all cells with the pictures
b.) Somehow implement an 'initiallyLoaded' property as in the AdjacencyStore (btw: there is a typo, it's called 'intiallyLoaded' ;) ), and do something similar as this in the column renderer: while(!feedStore.initiallyLoaded) { WAIT }


Any other suggestions? I don't like either of the ways, maybe you know what I should do :)

Thanks and best regards,

Nisse
User avatar
NisseKnudsenSystecs
Premium Member
Premium Member
 
Posts: 232
Joined: Mon Mar 21, 2011 11:09 am

Re: onLoad event for Store

Postby mats » Mon Mar 26, 2012 6:11 pm

Load taskstore in the load listener of the extra store? Or send back all data with the same dataset, faster and more elegant I guess. Also, refreshing the view on the extra store load would be fine too.
We're hiring! We have an open position for an experienced Sencha developer (Ext JS and/or Sencha Touch). Contact us at jobs@bryntum.com

Follow us on Twitter: @bryntum or Facebook

Need professional services or training? Read more here.
API documentation
User avatar
mats
Core Developer
Core Developer
 
Posts: 7073
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden

Re: onLoad event for Store

Postby NisseKnudsenSystecs » Tue Mar 27, 2012 9:49 am

Hey Mats!

Thanks for your answer! Acutally I first had it in the taskStore, but this wasn't performant at all. I just want to change a small flag, the is kind of associated with a task, but not in the same database table. So I had to distinguish if only this flag has changed or anything else on the task record. This would have taken too much time, so I create a second store!

But your load listener did the trick! :)

Now I have a small problem, which you might help me with: After succesfully setting/unsetting the flag via the second store, I would like to 'rerender' one cell in the gantt, actually it is one row in one of the columns. Is there a way for that?
User avatar
NisseKnudsenSystecs
Premium Member
Premium Member
 
Posts: 232
Joined: Mon Mar 21, 2011 11:09 am

Re: onLoad event for Store

Postby mats » Tue Mar 27, 2012 9:55 am

Nope, rerendering cells is not supported. You can add support for it, but you'll need to do plenty of digging inside of Ext JS GridView classes. Not recommended for a healthy lifestyle :)
We're hiring! We have an open position for an experienced Sencha developer (Ext JS and/or Sencha Touch). Contact us at jobs@bryntum.com

Follow us on Twitter: @bryntum or Facebook

Need professional services or training? Read more here.
API documentation
User avatar
mats
Core Developer
Core Developer
 
Posts: 7073
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden

Re: onLoad event for Store

Postby NisseKnudsenSystecs » Tue Mar 27, 2012 10:00 am

Haha :D Thanks for that honest answer ;);)

Actually I found another solution: On success of 'save' operation I just change the CSS class of that very cell, in case of failure it stays at it is (the only thing that changes is an icon) :)
User avatar
NisseKnudsenSystecs
Premium Member
Premium Member
 
Posts: 232
Joined: Mon Mar 21, 2011 11:09 am

Re: onLoad event for Store

Postby NisseKnudsenSystecs » Tue Mar 27, 2012 5:23 pm

Hey, one additional question:

Is it possible to block any click activity on a cell? Maybe by disabling onclick events or showing a layer on top of it?

Thanks!!
User avatar
NisseKnudsenSystecs
Premium Member
Premium Member
 
Posts: 232
Joined: Mon Mar 21, 2011 11:09 am

Re: onLoad event for Store

Postby mats » Tue Mar 27, 2012 6:04 pm

Why? Use case?
We're hiring! We have an open position for an experienced Sencha developer (Ext JS and/or Sencha Touch). Contact us at jobs@bryntum.com

Follow us on Twitter: @bryntum or Facebook

Need professional services or training? Read more here.
API documentation
User avatar
mats
Core Developer
Core Developer
 
Posts: 7073
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden

Re: onLoad event for Store

Postby NisseKnudsenSystecs » Wed Mar 28, 2012 8:50 am

The column contains a picture which has a onclick event. This event adds a record to the store OR removes a record from the store, depending on if it exists or not. The changes are sent to the server via DirectProxy.
This thing fails if someone clicks more than once inbetween a short time period on the icon, e.g. 4 times.

Maybe I shoudl just remove the event handler?
User avatar
NisseKnudsenSystecs
Premium Member
Premium Member
 
Posts: 232
Joined: Mon Mar 21, 2011 11:09 am

Re: onLoad event for Store

Postby NisseKnudsenSystecs » Wed Mar 28, 2012 9:40 am

Ok, never mind, I solved it with the event handler: when onClick is executed, the element is being set to elem.onClick = null; so you can try to double click as much as you want :D
User avatar
NisseKnudsenSystecs
Premium Member
Premium Member
 
Posts: 232
Joined: Mon Mar 21, 2011 11:09 am

Re: onLoad event for Store

Postby mats » Wed Mar 28, 2012 10:06 am

One click listener per cell sounds like a bad idea. Read up on event delegation here :) http://docs.sencha.com/core/manual/cont ... t-handling
We're hiring! We have an open position for an experienced Sencha developer (Ext JS and/or Sencha Touch). Contact us at jobs@bryntum.com

Follow us on Twitter: @bryntum or Facebook

Need professional services or training? Read more here.
API documentation
User avatar
mats
Core Developer
Core Developer
 
Posts: 7073
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden

Next

Return to Help (v1.x)

Who is online

Users browsing this forum: No registered users and 1 guest