We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Add new columns to Grid with grid.colums.push results in Error TS2349

Thread ID:

Created:

Updated:

Platform:

Replies:

144824 May 24,2019 11:51 AM UTC Jun 4,2019 07:24 AM UTC Angular - EJ 2 3
loading
Tags: Grid
Peter Falz
Asked On May 24, 2019 11:51 AM UTC

Hi Syncfusion-Team,

i tried to add new columns to Grid with grid.colums.push.
This results in Error TS2349 in Visual Studio before compiling.

How have i to do this the right way?
Maybe you can show me an example that works. :)

<ejs-grid #testGrid id='grid' class="margin-top-10 expense-grid-margin pane" height='100%' width='100%'
          allowPaging='true' [allowSorting]="true" allowSelection='false'
          [dataSource]='jsonDataWebService.DataList' [editSettings]='editSettings' [toolbar]='toolbarValue'
          (created)='onGridCreated()' (actionBegin)='onGridActionBegin($event)' (actionComplete)='onGridActionComplete($event)'
          (cellSave)='onGridCellSaved($event)'
          >
    <e-columns>
        <e-column width='100' textAlign='Center'>
            <ng-template #template let-data>
                <button id="gridEdit" type="button" title="Edit" class="e-lib e-btn e-control e-flat e-icon-btn e-edit-delete e-editbutton" (click)='onGridButtonEditClicked($event)'>
                    <span class="e-btn-icon e-icons e-edit"></span>
                </button>
                <button id="gridDelete" type="button" title="Delete" class="e-lib e-btn e-control e-flat e-icon-btn e-edit-delete e-deletebutton" (click)='onGridButtonDeleteClicked($event)'>
                    <span class="e-btn-icon e-icons e-delete"></span>
                </button>
            </ng-template>
        </e-column>
    </e-columns>
</ejs-grid>

let c = <Column[]>
        [ new Column( { field: "Id", headerText: "ID", width: "75", isPrimaryKey: true } ), 
          new Column( { field: "Key", headerText: "Key", width: "300" } ), 
          new Column( { field: "Name", headerText: "Name", width: "300" } ), 
          new Column( { field: "DateCreated", headerText: "Date Created", width: "200" } )
        ];
 
forlet i: number = 0; i < c.length; i++ ) {
    this.grid.columns.push( c[ i ] );
}
 
        // Test 2
        this.grid.columns.push( c );
 
 
        // Test 3
        let gc = this.grid.columns;
 
forlet i: number = 0; i < gc.length; i++ ) {
    this.grid.columns.push( gc[ i ] );
}

Fehler TS2349 (TS) Ein Ausdruck, dessen Typ eine Aufrufsignatur fehlt, kann nicht aufgerufen werden. Der Typ "((...items: string[]) => number) | ((...items: Column[]) => number) | ((...items: ColumnModel[]) => number)" weist keine kompatiblen Aufrufsignaturen auf.


Hope for help,
habe a nice day,
Peter

Pavithra Subramaniyam [Syncfusion]
Replied On May 27, 2019 07:30 AM UTC

Hi Peter, 
 
Greetings from Syncfusion support. 
 
You can update the Grid columns by using the below way. Please refer to the below code example and sample link for more information. 
 
[Component.ts] 
@Component({ 
    selector: 'app-root', 
    template: '<button (click)="click($event)">Columns</button> 
    <ejs-grid #grid [dataSource]='data' height='350'> 
        <e-columns> 
            <e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right'></e-column> 
            <e-column field='CustomerName' headerText='Customer Name' width='150'></e-column>           
        </e-columns> 
    </ejs-grid>' 
}) 
export class AppComponent { 
    .  .  . 
    click(e){ 
    let c = <Column[]> 
        [  { field: 'OrderDate', headerText: 'Order Date', width: 130, format: 'yMd', textAlign: 'Right' }, 
                { field: 'Freight', width: 120, format: 'C2', textAlign: 'Right' }, 
                { field: 'ShippedDate', headerText: 'Shipped Date', width: 140, format: 'yMd', textAlign: 'Right' }, 
                { field: 'ShipCountry', headerText: 'Ship Country', width: 150 } 
        ]; 
        for( let i: number = 0; i < c.length; i++ ) { 
    (this.grid.columns as Column[]).push( c[ i ] ); 
    this.grid.refreshColumns(); 
} 
  
    } 
} 
 
 
Please get back to us if you need any further assistance on this. 
 
Regards,  
Pavithra S. 


Peter Falz
Replied On June 3, 2019 01:37 PM UTC

thx for your help :)
Regards,
Peter

Pavithra Subramaniyam [Syncfusion]
Replied On June 4, 2019 07:24 AM UTC

Hi Peter, 
 
Thanks for your update. 
 
Please contact us if you need any further assistance. As always, we will be happy to assist you.  
 
Regards, 
Pavithra S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon