cancel
Showing results for 
Search instead for 
Did you mean: 

Table Column that disappears when there is no row value

Former Member
0 Kudos

Hi Gurus,

im trying to implement this event wherein when there is no value for a table row, the whole column disappears (or atleast becomes invisible).

I've already implemented javascript on the table row. This works when the table has only one line item (it makes the header invisible). But i have a problem, this table repeats itself for every line item (its in a subform, made to repeat for every line item), including the row headers. When there are two line items and both of them have no value, the code only works for the first line item. The code i used is as follows:


if ((data.ItemSF.ItemData.Row3.Cell5.rawValue == "") || (data.ItemSF.ItemData.Row3.Cell5.rawValue == null)) ->line item row
{
data.ItemSF.ItemData.Row3.Cell5.presence = "invisible";   -> line item row
data.ItemSF.ItemData.Row1.tariff.presence = "invisible";   ->column header
} 
else
{
data.ItemSF.ItemData.Row3.Cell5.presence = "visible";
data.ItemSF.ItemData.Row1.tariff.presence = "visible";
}

How can i be able to make it so that the second line items also becomes invisible when the row has no value?

Please help..

thanks in advance..

shockadis

Accepted Solutions (0)

Answers (2)

Answers (2)

OttoGold
Active Contributor
0 Kudos

I am not sure if I didn´t miss anything important, but what kind of addressing do you use? I would use the relative one- Like when you saysomething like this.presence = "hidden" (makes hidden the field on which this script is placed). Or this.field1 (this means current subform, field1 the field in that subform). Or this.parent (parent element of the field or subform).

regards Otto

Former Member
0 Kudos

Hi Otto,

i have tried using "this.presence" on the field, but for some reason, it doesnt work. i have no idea why.

i'm currently using the entire name of the cell, like the one in my opening post.

just making the column header invisible would be enough.

how should i name the column header, and how should i adresss it?

Thanks for the reply.

regards,

shockadis

Note: is there anyway to debug the javascript execution?

Former Member
0 Kudos

Hello,

I think there could a problem with Javascript which decides when the header has to be invisible. Because your table has 2 rows Material 123 and 456 and both need to have no data i suppose.

Like suppose material 123 is making it invisible but for some value in material 456 it again becomes visible.

Just guessing what might be the problem.

You can debug the javascript by giving pop up messages (xfa.host.messageBox) and have right values displayed in these popups.

Thanks & Regards,

Omkar Mirvankar.

OttoGold
Active Contributor
0 Kudos

If you would like to manipulate the field/ column in every row, then you need addressing like DATA[*] as in the binding what I cannot see in your code and that is why it cannot work, I think.

If you need to manipulate only the header of the column, then use initialize event, java script and place the code on every field header (like on the text field or something, if it is only a static text, it cannot launch javascripts, I believe), of course use your condition but together with the relative addressing. If you think the addressing in the form is not funny (like me), you can always check if you want to display the column in the backend and add an extra flag, so you will test only one static structure field instead of looping at the table or something else suicidal...

Regards Otto

Former Member
0 Kudos

Hi Otto,

so i've placed the script in the column header, and simplified it since its the onl field i need to disappear when the column is empty.


if ((??.rawValue == "") || (??.rawValue == null))
{
this.presence = "invisible";
} 
else
{
this.presence = "visible";
}

how should i relatively address the cell with the question marks when the table repeats itself for every line item?

__________

|_tariffCode_| ->i've placed the script (initialize) here

|___??_____| -> this is the reference cell

__________

|_tariffCode_| ->i've placed the script (initialize) here

|___??_____| -> this is the reference cell

@Omkar:

Hi, what i had in the picture was just a sample. the column header has only 1 field as reference if it should be visible or invisible.

Thanks for the help guys.

regards,

shockadis

OttoGold
Active Contributor
0 Kudos

should be like:

this.parent.??.rawValue == "" (like: start here, go up, go down using ?? as name, get property)

regards Otto

Former Member
0 Kudos

Sorry Otto, but it doesnt work. this is really starting to get frustrating.. does it matter if i set the script to run on client and server?


if ((this.parent.tariffVal.rawValue == "") || (this.parent.tariffVal.rawValue == null))
{
this.presence = "invisible";
} 
else
{
this.presence = "visible";
}

ive used this code on the column header. any other thoughts?

the reference field is named as tariffVal

i have also tried placing the script on the repeating subform (initialize) like this


if ((this.tariffVal.rawValue == "") || (this.tariffVal.rawValue == null))
{
this.tariffCode.presence = "invisible";
} 
else
{
this.tariffCode.presence = "visible";
}

still doesnt work.. did i mention that inside the subform, theres a table, and the column is in the table..?

regards,

shockadis

OttoGold
Active Contributor
0 Kudos

Oooh, man. send me the form or it will take us like decades, Otto

Former Member
0 Kudos

Nice! i changed the script so that all the stuff inside the subform were in the name.


if ((this.ItemData.Row3.tariffVal.rawValue == "") || (this.ItemData.Row3.tariffVal.rawValue == null))
{
this.ItemData.Row1.tariffCode.presence = "invisible";
} 
else
{
this.ItemData.Row1.tariffCode.presence = "visible";
}

thanks for the hint.

regards,

shockadis

closed.

Former Member
0 Kudos

Hello,

Please tell us on which event have you writen this code.

Do try on the initialise event of the subform.

Thanks & Regards,

OMkar Mirvankar.

Former Member
0 Kudos

Hi Omkar,

I have placed this on the initialize event. The code does work when there is only one line item. in the form i have designedI have this table that duplicates itself for every line item. for example:

i have two line items.

please click.

http://images.plurk.com/3259487_b3627e16259c66f2e7a0908e57ab8b00.jpg

for table 2, even though the tariff column has no data, it is still showing. i want it also to be invisble

regards,

shockadis