aurelia-v-grid / vGrid

Aurelia-v-grid - npm source
MIT License
49 stars 10 forks source link

Please add an event, when the grid is totally ready for anykind of use... #80

Closed JOKaija closed 7 years ago

JOKaija commented 7 years ago

I need it for initial filtering to put "*"-method to all columns. And some filterin strings too...

I can create a delay timer, but it is stupid. I would like fire setInitialFilters() as soon as the grid can handle it without ruining everything...

Now you have:

collection_filtered
selection_changed

Event called: grid_ready_foruse

would be nice :-)

vegarringdal commented 7 years ago

k, so problem is that headers does not have the correct value? would be better if grid checked if any filters where set by it self and updated, same with sort order

should not be a problem to create event either, since it already tells the gridconnector when its created

Ill have a look at this after work when I have time.

JOKaija commented 7 years ago

Thanks. The problem is now, that when user opens web page, I can't setup filters without delaytimer. If I try to set them on the end of attached() event, they will not be set. If I try to set them on checking, that grid event have more than 0 entities filtered and collection filtered, it doesn't work either. Too soon. If I fire that same setInitialFilters by button. Everything works fine. But....

vegarringdal commented 7 years ago

You can check if the datasource have more then 0 entities, its not connected to grid at all How it works is that the dataosurce is connected to gridConnector, the gridConnector gets binded to the grid code. When grid code starts to run, it calls a "connect" method in gridConnector, that then callback to tell grid to create/build, when grid is created it calls the "created" method in gridConnector

As a quick fix until I get it fixed you can do this:

Copy this to you project and and inport that instead of the grids connector (just remove the typings etc if you dont use typescript) https://github.com/vegarringdal/vGrid/blob/dev-rebuild/src/gridConnector.ts

After this line you add: https://github.com/vegarringdal/vGrid/blob/dev-rebuild/src/gridConnector.ts#L87

this.raiseEvent("filterUpdateValues")

That will force all the inputs to update its values, it shoul solve you issue, and you should not need to think about if the grid is ready or not

Both the datasource and gridConnector can be custom if needed. Wanted to have it this way so someone can modify it for remote data etc if needed, impossible for me to cover every use case.

Thsi is the reason why Ive tried to write as mush as possible comemnts in these files

vegarringdal commented 7 years ago

Im gonna now test if that line solves what I tried to say earlier today :-)

vegarringdal commented 7 years ago

@JOKaija

Now grid updates and get filters after its created, no need for event Please verufy and close issue

You can also do after query this.ds.orderBy("high")

vegarringdal commented 7 years ago

Update:

Now you should also be able to set the grouping at the beginning, or just by code when you want... Might be some bugs in the grouping part I dont know about, had to rewrite a lot, will need to clean that part up a bit more

this.ds.setArray(this.myCollection);
this.ds.query([{attribute: 'index', operator: '<', value: 5 }]);
this.ds.group([{title: 'My Country', field: 'country'}, {title: 'My bool', field: 'bool'}]);
this.ds.orderBy('high');
JOKaija commented 7 years ago

works. thanks

vegarringdal commented 7 years ago

Great 👍