jQWidgets Forums

jQuery UI Widgets Forums Angular Set localdata in Dynamically created grid

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  gudboisgn 7 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Set localdata in Dynamically created grid #98928

    gudboisgn
    Participant

    I have Created Grid Columns Dynamically, that work fine and grid header render succesfully, but, when i set localdata of grid, it doesnot display the grid data. I console.log(this.dynamicSource); shows datafield & localdata in console. but grid is not loaded with data.

    // grid Datafield source

       this.dynamicSource = {
          datatype: 'json',
          datafields:[],
          localdata: [],
          updaterow: (rowid: any, rowdata: any, commit: any): void => {
            commit(true);
          },
        };

    // grid Column

      dynamicColumn:any = [
          {
            text: 'Sn', sortable: false, filterable: false, editable: false,
            groupable: false, draggable: false, resizable: false,
            datafield: 'sn', columntype: 'number', width: 50,
            cellsrenderer: (row: number, column: any, value: number): string => {
                return '<div style="margin: 4px;">' + (value + 1) + '</div>';
            }
          }
        ];

    //Create Dynamic Grid
    `createGrid(data){
    for(let i = 0; i < data[‘subjects’].length; i++){
    let newCol = {
    text: data[‘subjects’][i][‘name’], datafield: data[‘subjects’][i][‘code’]+’_mark’, columntype: “textbox”
    };

    this.dynamicColumn.push(newCol);

    this.dynamicSource.datafields.push({ name: data[‘subjects’][i][‘code’]+’_mark’, type: ‘number’ });

    }

    this.dynamicSource.localdata = data[‘students’];

    this.dynamicAdapter = new jqx.dataAdapter(this.dynamicSource,{autoBind: true,});

    this.examSubjectGrid.updatebounddata();

    console.log(this.dynamicSource);

    }`

    Set localdata in Dynamically created grid #98935

    Stanislav
    Participant

    Hello gudboisgn,

    Have you tried refreshing the grid after you update the DataAdapter?
    Try with this:

    
    ngAfterViewInit(): void 
        {
            this.myGrid.refresh();
        }
    

    Best Regards,
    Stanislav

    jQWidgets Team
    http://www.jqwidgets.com/

    Set localdata in Dynamically created grid #98940

    gudboisgn
    Participant

    Hello Stanislav,

    I tried to refresh grid after updating DataAdapter, like this shown below but column header get rendered but none of the localdata are being rendered.
    i have tried.

        this.dynamicSource.localdata = data['students'];
        this.dynamicAdapter = new jqx.dataAdapter(this.dynamicSource,{
          autoBind: true,
        });
        
        this.examSubjectGrid.refresh();

    I have also, tried:

    this.examSubjectGrid.refreshData();
    this.examSubjectGrid.render();
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.