This is a migrated thread and some comments may be shown as answers.

Wrapper grid dynamic column binding issue

1 Answer 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RR
Top achievements
Rank 1
RR asked on 21 Apr 2020, 08:33 AM

 

hi, 

I have used vue wrapper grid, columns binding as a list.  Columns are binded. 

 

ColumnList is as follows.

 

I use a seperate method to change this column list. later. There I add new columns to the grid as well. 

createContactGridWithCustomFields(customFields: []) {
  
   if (this.commonContactInfo.customFieldsForGroups.length > 0) {
     let Customcolumns: any[] = [];
     let field = '';
     let cusFieldId = '';
     this.commonContactInfo.customFieldsForGroups.forEach((cf:CustomFieldsDto) => {
       if (cf.pkFieldId !== undefined) {
         cusFieldId = cf.pkFieldId;
       }
       console.log('cfid:', cusFieldId);
       this.commonContactInfo.fetchedContactsList.forEach((cont:ContactDto) => {
         Object.keys(cont.customFields).forEach(k => {             
           if (this.commonHelper.getPlainGuidString(k) === cusFieldId) {
             if (cont.customFields[k].DataType === 'DateValue') {
               console.log(cont.customFields[k].DateValue);
               field = 'customFields[' + k + '].DateValue';
             }
             if (cont.customFields[k].DataType === 'StringValue') {
               console.log(cont.customFields[k].StringValue);
               field = 'customFields[' + k + '].StringValue';
             }
             if (cont.customFields[k].DataType === 'IntValue') {
               console.log(cont.customFields[k].IntValue);
               field = 'customFields[' + k + '].IntValue';
             }       
           }
         });
       });
      
       Customcolumns.push({
         title: cf.fieldName,
         field: field, // 'customFields[' + field + '].DateValue',
         selected: true,
         disabled: true,
         isVisible: true,
         width: 150
       });
     });
     
     let defcolumns = this.helperService.loadGridColumns();
     Customcolumns.forEach((tc:any) => {
       defcolumns.push(tc);
     });
   }
 }

 

columns are added like this because the data i have is as follows. datafieldvalue

 Issue is after this even the columns are added the data in not binding.

Any suggestions?

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 22 Apr 2020, 12:07 PM

Hello,

Here you can find one example how to use dynamic columns in Kendo Vue Wrapper - https://stackblitz.com/edit/2v8gaj-9hq1dr?file=index.js.

You could also check an example with the Native Kendo Grid for Vue that was where dynamic columns are an easy task-  https://stackblitz.com/edit/wanzoc-n7zn9y?file=index.js .

 

Regards,
Plamen
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
RR
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or