Page 1 of 1

Number of columns of a grid

Posted: Thu Oct 21, 2021 2:44 pm
by kleung
Hi,

Grateful if I can be advised the methods of getting the number of columns of a grid by
1) javascript in dynaform and
2) php in trigger.

Thousand Thanks.

cheers,
karl

Re: Number of columns of a grid

Posted: Thu Oct 21, 2021 9:58 pm
by kirkwg
Hello Karl,

Long time no see you in here....
Since there is no getNumberColumns() function for Grid, meant you need to write your own function.

Give you some hints on JS to do that:
1/ var gValues = $("#grid_id").getValue(); //get all values
2/var columns = gValues[0].length;

For trigger:
you could pass your columns to a hidden_variable or case variables
At trigger, retrieve back the hidden_var or case_var

Good luck , better try it, cheers.

Re: Number of columns of a grid

Posted: Thu Oct 21, 2021 10:06 pm
by kleung
Hi Kirk,

How are you?
Yes, haven't post message here for some time, especially after the departure of Amos.

Thank you for your advice. I'll try them.

cheers,
Karl

Re: Number of columns of a grid

Posted: Thu Oct 21, 2021 10:11 pm
by kirkwg
those 2 JS lines is working even when the grid is with one empty row .
Not working when the grid is clear, i.e. no rows at all.

Re: Number of columns of a grid

Posted: Thu Oct 21, 2021 10:14 pm
by kleung
Hi Kirk,

Thx for your kind attention.

cheers,
Karl

Re: Number of columns of a grid

Posted: Fri Oct 22, 2021 12:59 pm
by kleung
Hi,

Accidentally, in https://www.pmusers.com/index.php/Copy_Grid, I found the following codes can also obtain the number of columns of a grid.

var aCols = $('#gridID').getInfo().columns;
var gColNo = aCols.length;

cheers,
Karl