Author Topic: How can I change multiple title.  (Read 2192 times)

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
How can I change multiple title.
« on: January 16, 2020, 06:27:13 pm »
I can change the column heading in this way when I click on the row.

Code: [Select]
,rowClick: function( event, ui ) {
ui.column.title='New Header-1';
grid.refreshHeader();
}

Can I do something like this?
Code: [Select]
,rowClick: function( event, ui ) {

ui.column['Header-1'].title='New Header-1';
ui.column['Header-2'].title='New Header-2';
ui.column['Header-3'].title='New Header-3';
ui.column['Header-4'].title='New Header-4';

grid.refreshHeader();
}


Actually, what I want to do is exactly as follows.
Code: [Select]
,rowClick: function( event, ui ) {

if (ui.column.dataIndx=='Header-1') {ui.column.title='New Header-1';}
if (ui.column.dataIndx=='Header-2') {ui.column.title='New Header-2';}
if (ui.column.dataIndx=='Header-3') {ui.column.title='New Header-3';}
if (ui.column.dataIndx=='Header-4') {ui.column.title='New Header-4';}


grid.refreshHeader();
}


That's the change I want. But I have to define all the fields.
Code: [Select]
,rowClick: function( event, ui ) {

var colModelNew = [{title: 'ID','dataIndx':'ID'},{title: 'New Header-1','dataIndx':'Data1'},{title: 'New Header-2','dataIndx':'Data2'},{title: 'New Header-3','dataIndx':'Data3'},{title: 'New Header-4','dataIndx':'Data4'},{title: 'Other Header-1','dataIndx':'Data5'},{title: 'Other Header-2','dataIndx':'Data6'}]

grid.option('colModel', colModelNew);
grid.refreshCM();
grid.refresh();

}

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: How can I change multiple title.
« Reply #1 on: January 16, 2020, 08:53:16 pm »
you can use each method of Columns object to assign new titles to multiple columns.

https://paramquery.com/pro/api#method-Columns