Categories > TinyButStrong general >

Merge columns

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Gil
Date: 2012-08-09
Time: 18:36

Merge columns

Hi,

Is it possible to merge MS Word table columns when a variable on a block isnt null?

Like i have this table

[base_sub1.number] | [base_sub1.name;block=w:tr] | [data_sub1.canceled] |                 |                 |                 |                 |    

now i want, if "canceled" have a value, to merge all the other columns.. Is that possible?

Any help would be appreciate.
Best Regards

        
By: Skrol29
Date: 2012-08-09
Time: 23:49

Re: Merge columns

Hi Gil,

>now i want, if "canceled" have a value, to merge all the other columns..

What do you mean by "merge all the other columns"?
The columns must be empty if "canceled" is empty, and if "canceled" is not empty extra columns must be merged with what?
By: Gil
Date: 2012-08-10
Time: 10:48

Re: Merge columns

Hi,

[base_sub1.number] | [base_sub1.name;block=w:tr] | [data_sub1.canceled](1) |                 (2)|                 (3)|                 (4)|                 (5)|  

if "canceled" have a value i want to merge 1,2,3,4 and 5 columns..

the idea is to have one big column instead of all the others(with numbers) when 'canceled' have a value..

thanks for ur help ;)
Best regards

By: Skrol29
Date: 2012-08-11
Time: 23:26

Re: Merge columns

Hi,

You can use parameter "if" on each optional columns.
But the smartest way is to arrage data using parameter "ondata".

[base_sub1.number] | [base_sub1.name;block=w:tr;ondata=f_ondata] | [data_sub1.canceled] | [data_sub1.col2] | [data_sub1.col3] | [data_sub1.col4] |

At the PHP side:
function f_ondata($BlockName,&$CurrRec,$RecNum) {
  $CurrRec['col2'] = ($CurrRec['canceled']=='') ? '' :  $CurrRec['real_col2'];
  $CurrRec['col3'] = ($CurrRec['canceled']=='') ? '' :  $CurrRec['real_col3'];
  $CurrRec['col4'] = ($CurrRec['canceled']=='') ? '' :  $CurrRec['real_col4'];
}
By: Gil
Date: 2012-08-11
Time: 23:32

Re: Merge columns

Hi,

That will merge the columns? where should i put that function? :s
By: Skrol29
Date: 2012-08-12
Time: 00:59

Re: Merge columns


>That will merge the columns?

In your snippet you have blocks "base_sub1" and "data_sub1". Is that a mistake ?
It is should be the same block, then it has to be renamed in my snippet too.

The PHP function add new columns in your recordset. Each column in the template are merged using its TBS fields.

> where should i put that function?

Where you want. User PHP functions are global.
Nevertheless, you can also use a method instead of a function. See http://www.tinybutstrong.com/manual.php#html_block_prm_ondata