Create Servoy Extra Table dynamically

Hi All,

I am working in NG Desktop client and need to create Servoy Extra Table web component dynamically.

Any help will be highly appreciated.

Regards

Hi

Create a form and put an empty table component on that and give this component a name (in my example “meinetabelle”) so you can reference this. Of course you can even do this with SolutionModel.

Then, in the onLoad-Event, you can put something like this:

function onLoad(event) {
	
	var meineTabelle = elements.meinetabelle; // Look for the "table"-component
	
	meineTabelle.addStyleClass("mycss"); // set the style class of my table with the api
	
	var datumFeld = meineTabelle.newColumn("datum_vorgaenge"); // create a new column with dataprovider "datum_vorgaenge"; return a "column"-object
	
	// Set the different properties for the column
	datumFeld.headerText = "Vorgangsdatum";
	datumFeld.width = 250;
	datumFeld.format = "dd.MM.yyyy";
	
	// more columns to come...
}

Also have a look here: https://github.com/Servoy/servoy-extra- … wiki/Table

Hope this gives you an idea.

Best
Roland

Thanks for you response.

If we need to create table completely from code, then how to achieve this?

As I have tried following code but its not working.

var detailForm = solutionModel.getForm("test2");
var table = detailForm.newWebComponent('table1','servoyextra-table');

Any help will be highly appreciated.

Regards

Hi,

if you create the table with solutionModel. You can use the setJSONProperty(“columns”, myArrayOfColumns);

var columns = [];

/** @type {CustomType<servoyextra-table.column>} */
var column = {};
column.dataprovider = "productid"
column.headerText = "Product"
column.valuelist = "products"
columns.push(column);
table.setJSONProperty('columns',columns);

Regards,
Paolo

paronne:
Hi,

if you create the table with solutionModel. You can use the setJSONProperty(“columns”, myArrayOfColumns);

var columns = [];

/** @type {CustomType<servoyextra-table.column>} */
var column = {};
column.dataprovider = “productid”
column.headerText = “Product”
column.valuelist = “products”
columns.push(column);
table.setJSONProperty(‘columns’,columns);




Regards,
Paolo

Thanks Paolo for your response. It worked for me.

Roland, I appreciate your efforts too.

Marking this thread as RESOLVED.

Regards