How could we bind data from store such as ngrx (Angular)

506 views Asked by At

I am working on a project and binding devextreme data grid from ngrx store in angular application. I am dispatching an action and based on action my redux store is being updated i.e. grid data is being fetched from the api. I am dispatching my action inside the load function of customstore of devextreme.

this.gridDS.store = new CustomStore({

        load: (loadOptions: any) => {


            params += 'skip=' + loadOptions.skip || 0;
            params += 'take=' + loadOptions.take || 15;

            if (loadOptions.sort) {
                params += '&orderby=' + loadOptions.sort[0].selector;
                if (loadOptions.sort[0].desc) {
                    params += ' desc';
                }
            }

            if (params === '?') {params =  '?skip=0&take=3' }
            this.ngRedux.dispatch(this.commonActions.getGrid(params));

            return  this.ngRedux.select(['common', 'csGridData'])
                        .toPromise()
                        .then((result: any) => {

                          return { data: result.data, totalCount: result.totalCount};
                                            })
                        .catch(error => { });




        }
    });

Here is a link of DevExtreme Demo

Could anyone help me.

Thanks in advance

0

There are 0 answers