Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate Data In Grid Without Database #3941

Closed
TechAspirant opened this issue Sep 22, 2018 · 10 comments
Closed

Populate Data In Grid Without Database #3941

TechAspirant opened this issue Sep 22, 2018 · 10 comments

Comments

@TechAspirant
Copy link

How Can I Populate static data in grid ? I have created GridStaticDataColumn.cs / GridStaticDataGrid.ts / GridStaticDataIndex.cshtml and GridStaticDataPage.cs File. Below is my code for GridStaticDataGrid.ts, what to populate in Serenity.EntityGrid<> and I am getting Error after running as
each data element must implement a unique 'id' property

@Serenity.Decorators.registerClass()
export class GridStaticDataGrid extends Serenity.EntityGrid<**What to Populate**, any> {
    protected getColumnsKey() { return 'MasterData.GridStaticData'; }

    constructor(container: JQuery) {
        super(container);
        var data = [];
        for (var i = 0; i < 1; i++) {
            data[i] = {
                Id: Math.round(Math.random() * 100),
            };
        }
        this.view.setItems(data, true);
    }
    protected getGridCanLoad() {
        return false;
    }
}
@ga5tan
Copy link

ga5tan commented Sep 22, 2018

I think there are some samples about populating grids from SP, or else, maybe check that?

@TechAspirant
Copy link
Author

I want that data to be populate from string not from Stored Procedure

@minhhungit
Copy link
Contributor

I think that is because slickgrid does not know what is your Id name

For example:

export class GridStaticDataGrid extends Serenity.EntityGrid<**What to Populate**, any> {
   protected getColumnsKey() { return 'MasterData.GridStaticData'; }
   protected getIdProperty() { return "Id"; } // <================== add this line

   constructor(container: JQuery) {
       super(container);
       var data = [];
       // ...
       // ...

@minhhungit
Copy link
Contributor

or change Id name of your data to id, not Id, for example:

data[i] = {
    id: Math.round(Math.random() * 100),
};

@TechAspirant
Copy link
Author

What to Populate ......I dont Have StaticDataGridRow.cs so what to pass there

@minhhungit
Copy link
Contributor

LOL, they are your code, I just copied it, where did you get them ?

Normally, you will need to create your own Row.cs class and Column.cs class, then generate it by transforming t4 template, after that:

  • What to Populate: will be your Row.ts
  • MasterData.GridStaticData: is form script on Column.cs

@ga5tan
Copy link

ga5tan commented Sep 22, 2018

well u dont need SP, but I thought, if u check the sample, u will learn how to pass data (from SP in sample/but in your case from string) to SlickGrid.

another option is to check github for Slick Grid

I am importing data from various sources (files, but string in the end), create entity instances and assign them to InMemory grid in Master/Detail scenario.

so I know it's possible, to stick anything into grid. (in my case I have DB entity to serve as intermediary, but quite likely you can fake you own enTITY?

@TechAspirant
Copy link
Author

Adding *Row.cs and Transforming to T4 Template , *Row.ts file gets created after that removed , in
Id: Math.round(Math.random() * 100), as I am having only one column
After that everything worked well

@TechAspirant
Copy link
Author

TechAspirant commented Sep 22, 2018

Thanks @ga5tan & @minhhungit

One more doubt @Serenity.Decorators.filterable() is not working in my case. When I click on edit filter to add criteria then grid is not getting filtered with the added crteria

@minhhungit
Copy link
Contributor

About @filterable() it will not work, you must implement it by manual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants