aurelia-v-grid / vGrid

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

Error when setting collection #20

Closed Vaccano closed 8 years ago

Vaccano commented 8 years ago

In my grid, searchResults is bound to the collection. When I set search results, I get the following error:

Cannot read property 'clearHeaderSortFilter' of undefined

It looks as if gridContext.ctx' is not defined. In fact, grid context only has aproto` on it.

This is in enableObservablesCollection.

This may be of note: Before I set searchResults the screen had not painted the grid. (I was wondering if it would be painted once there was data. I will try to debug that as a work around to this issue.) I note this because this issue may be caused by that issue.

vegarringdal commented 8 years ago

On the component/page ,you either replace array or push/pop/splice the collection array you have passed into the config attribute. In the config attribute you have to add at minimum -current-entity.bind:xxxx -collection.bind:xxx collection you bind to have to be a array and current entity a object

page.page

<v-grid
        style="position:relative;margin-left:25px;width:%; height:500px"
        row-height="25"
        header-height="50"
        config="current-entity.bind:myCurrentEntity; collection.bind:myCollection">
    <v-grid-row>
        <v-grid-col attribute="index"   header="Index"   ></v-grid-col>
        <v-grid-col attribute="name"   header="Name"  ></v-grid-col>
    </v-grid-row>
</v-grid>

page.js

export class mypage{

  constructor(){
    // you could add data to the grid here by adding data to this.myCollection in you page, or later.
}

  myCollection = [];
  myCurrentEntity = {};

}

The only thing I add to "myCollection" on the page is a "__sgkey3243" so I know whats what when sorting etc to manage to know how to set selection etc.

if you have not set the collection you bind as a array then it will fail at load time, there does not haveto be data in the array

Tell me how it goes, you trying to use it is a good thing, will make it clear what I need to improve in the how to use if anything is unclear.

Vaccano commented 8 years ago

That was it. My bad for not following the directions close enough.

Looking good so far.

vegarringdal commented 8 years ago

Have a huge tabbing feature Im working on atm, that and my constant improving the code to best I can. So next weeks there will be many internal changes to please try and stay away from the internal functions: early demo on tabbing if you want to test (double click on cell to enter edit mode) when not in edit mode you can navigate with arrow keys all directions, when in edit mode only up and down/tab

http://vegarringdal.github.io/vGrid/demo002/

Vaccano commented 8 years ago

Initial testing of the new version with it looks good to me.

Vaccano commented 8 years ago

@vegarringdal The current version has a bug that is fixed in the new newer version. I am assuming it is a waste to report bugs like that. Let me know if you would rather have them reported.

vegarringdal commented 8 years ago

Im doing a lot of changes because Ive done som bad parts bacuse I didnt know better, grid was not es6 code before, so after I did that change over I could remove a lot of junk, also tries to follow improve the code I have before going to crazy with new features :-) But if you see bugs in the demo002 then please report them, because Ive been doing a lot of changes and might have broken some parts I havent seen yet