Make column in a Data Grid with editType CHECKBOX readonly

Questions and answers for designing and implementing forms in Servoy

Make column in a Data Grid with editType CHECKBOX readonly

Postby huber » Thu Feb 02, 2023 2:51 pm

How to make a column in a Data Grid with editType CHECKBOX (and some others) readonly (at design time)?

Servoy Developer 202206

Best regards
Robert Huber
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
huber
 
Posts: 518
Joined: Mon May 14, 2012 11:31 pm

Re: Make column in a Data Grid with editType CHECKBOX readon

Postby mboegem » Thu Feb 02, 2023 5:01 pm

Hi Robert,

I believe this can be done by using the 'isEditableDataprovider' (column property)
If you want it read only, you should assign a dataprovider that returns false.

Hope this helps
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1749
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Make column in a Data Grid with editType CHECKBOX readon

Postby huber » Fri Feb 03, 2023 11:41 am

Hi Marc

Many thanks - works as you say.

It did help :-)

Best regards,
Robert Huber
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
huber
 
Posts: 518
Joined: Mon May 14, 2012 11:31 pm

Re: Make column in a Data Grid with editType CHECKBOX readon

Postby antonio » Sun Feb 19, 2023 9:55 am

Thanks for that tip.
On a similar theme how would we show/hide a column on Data Grid programatically in NG client.
Tony
Servoy 8 - 2022.03 LTS
antonio
 
Posts: 638
Joined: Sun Apr 02, 2006 2:14 am
Location: Australia

Re: Make column in a Data Grid with editType CHECKBOX readon

Postby cmanolescu » Mon Jan 29, 2024 11:55 am

Hello Antonio,

You can do that in a function, for example on Load.
Just loop over the columns and do your needed if-s etc.

Code: Select all
/**
* Callback method when form is (re)loaded.
*
* @param {JSEvent} event the event that triggered the action
*
* @properties={typeid:24,uuid:"630DDFF5-8352-4EF0-8FC3-137CD9DD6E40"}
*/
function onLoad(event) {
   /** @type {CustomType<aggrid-groupingtable.column>} */
   var columns = elements.datagrid_1.columns;
   for (var index = 0; index < columns.length; index++) {
      columns[1].columnDef = {
         suppressMenu: true
      }
      columns[1].visible = false;
   }
}


Or if you only need a specific column.

Code: Select all
   /** @type {CustomType<aggrid-groupingtable.column>} */
   var col2= elements.datagrid_1.columns[2];
   col2.columnDef= {
      suppressMenu: true
   }
   col2.visible= false;
cmanolescu
 
Posts: 2
Joined: Wed Oct 19, 2022 4:15 pm


Return to Forms

Who is online

Users browsing this forum: No registered users and 7 guests

cron