Checkbox in Servoy DataGrid

Forum to discuss the new web client version of Servoy.

Checkbox in Servoy DataGrid

Postby dev-ws-011 » Mon May 06, 2019 1:47 pm

Hi,

I am working on NG Client and creating UI which is utilizing Servoy NG-Grids -> DataGrid.

Foundset which is bound to DataGrid contains following fields of interest:
[*] Boolean(Check Box) (for selection)
[*] Text field (for description/detail of product)
[*] Date (for date of last stock updated)

I have successfully mapped text field and Date in DataGrid but cannot find a way to add Check Box as column in DataGrid. (In column 'editType' property, we can only select TextField, DatePicker, ComboBox or TypeAhead. No option for Check Box).

Any assistance in resolving above will be highly appreciated.

Thanks
Servoy Developer
dev-ws-011
 
Posts: 11
Joined: Fri Oct 21, 2016 8:23 am

Re: Checkbox in Servoy DataGrid

Postby paronne » Wed May 15, 2019 2:31 pm

Hi,

in the current version of the Data Grid there is not a check box editType indeed.
Is possible to implement the check-box behavior using the styleClassDataprovider for your "check-box column". The styleClassDataprovider will be a calculation returning a font-icon (e.g. Font Awesome icon).

For example let's assume your foundset has a column 'active' and you want to show in the grid all records where the value active = 1

Code: Select all
function isActiveStyleClass() { // calculation to be used as styleClassDataprovider
   return (active=== 1) ? 'fas fa-check-square' : 'fas fa-square';
}


You can then change the check foundset's active value using the onCellClick event of the grid, toggling the active value from 0 to 1.
paronne
 
Posts: 118
Joined: Fri Nov 02, 2012 3:21 pm

Re: Checkbox in Servoy DataGrid

Postby dev-ws-011 » Mon May 20, 2019 12:39 pm

paronne wrote:Hi,

in the current version of the Data Grid there is not a check box editType indeed.
Is possible to implement the check-box behavior using the styleClassDataprovider for your "check-box column". The styleClassDataprovider will be a calculation returning a font-icon (e.g. Font Awesome icon).

For example let's assume your foundset has a column 'active' and you want to show in the grid all records where the value active = 1

Code: Select all
function isActiveStyleClass() { // calculation to be used as styleClassDataprovider
   return (active=== 1) ? 'fas fa-check-square' : 'fas fa-square';
}


You can then change the check foundset's active value using the onCellClick event of the grid, toggling the active value from 0 to 1.


Thanks paronne for your help. I will try this and will update you. Hopefully it will work for me. :)
Servoy Developer
dev-ws-011
 
Posts: 11
Joined: Fri Oct 21, 2016 8:23 am


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 2 guests