function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
cedgcedg 

not repeating table with inputfield

Hi,

 

I try to have a table in a visualforce page, but not a repeating table, so i cannot use <apex:dataTable>.

First column with label (big width) and then 2 columns with input fields (smaller width).

 

Have i to use the <apex:inputfield> for the fields ? 

If yes, how can i make them appear on the same line ? They appear always on separate line.

If no, how can i make the <input> related to the SFDC fields so as to save the value in the correct field ?

 

I tried this : 

<table border="1">
<tr><td colspan="2"></td><td  colspan="2">Total</td><td  colspan="2">Part</td></tr>
<apex:outputText >Label bla bla</apex:outputText>
<apex:inputField value="{!Building_Cost__c.CA1a_Real_Rent_Total__c}" label=""/>
<apex:inputField value="{!Building_Cost__c.CA1a_Real_Rent_Part__c}" label=""/>
</table>

 

Thanks for your help

Ced

 

 

Best Answer chosen by Admin (Salesforce Developers) 
rklaassenrklaassen

Apparantly the renderer is trying to merge the field with the table, because I also see a tbody tag out of nowhere...

I don't know how to solve this without trying it myself, but maybe this is a solution for you:

<apex:panelGrid columns="3" id="theGrid">
  
  <apex:outputText value="Desc" />
  <apex:outputText value="Total" />
  <apex:outputText value="Part" />
  
  <apex:outputText >Label bla bla</apex:outputText>
  <apex:inputText value="{!Building_Cost__c.CA1a_Real_Rent_Total__c}" />
  <apex:inputText value="{!Building_Cost__c.CA1a_Real_Rent_Part__c}" />

</apex:panelGrid>

 It will render a table the way you want it?

All Answers

rklaassenrklaassen
<table border="1">
  <tr>
    <td colspan="2"></td>
    <td colspan="2">Total</td>
    <td colspan="2">Part</td>
  </tr>
  <tr>
    <td><apex:outputText >Label bla bla</apex:outputText></td>
    <td><apex:inputField value="{!Building_Cost__c.CA1a_Real_Rent_Total__c}" /></td>
    <td><apex:inputField value="{!Building_Cost__c.CA1a_Real_Rent_Part__c}" /></td>
  </tr>
</table>

 Something like this?

cedgcedg

I tried that at first, but then i've empty lines, as if the <tr> and <td> of the inputfield was not containing the <inputfield>. And the last column is never containing a field.

rklaassenrklaassen

Field Level Security on the inputfields maybe?

cedgcedg

sorry i was not clear, the fields appears on the page, but never in the last column and always on separate lines.

cedgcedg

and thus when writing <tr><td><apex:inputfield ...

it renders first an empty line, and then a line with the input field.

rklaassenrklaassen

Yeah oke, then it's an issue with the inputField tag. Can you use inputText instead? That will work in this case AFAIK!

cedgcedg

and if i try something like 

 <table border="1">
            <tr><td ></td><td  >Total</td><td  >BEE</td></tr>
            <tr>
                <td>test</td>
                <td><input type="text" value="{!Building_Cost__c.CA1a_Real_Rent_Total__c}" /></td>
                <td><input type="text" id="{!Building_Cost__c.CA1a_Real_Rent_Part__c}" /></td>
            </tr>
            
            </table>

 the rendering is ok, the default value is correct, but it's not saved in the real SFDC field.

 

In this case, I've no controller for my VF page, i use only it to overwrite the standard display.

 

I guess I could create a controller, overwrite the Save command and save all the values of VF fields in the corresponding fields, but I'm wondering if there is nothing easier to do.

cedgcedg

same same

<inputText> appear each time on a new line of the table

rklaassenrklaassen

Last try then: standardStylesheets="false" in your page tag?

cedgcedg

no, still the same issues :(

rklaassenrklaassen

What's the html the page renders? Can you share that?

cedgcedg

here is the HTML source of the table

<table border="1" width="100%">
  <tbody><tr>
      <td colspan="2" width="60%">Desc</td>
      <td colspan="2" width="20%">Total</td>
      <td colspan="2" width="20%">Part</td>
    </tr>
    <tr><td></td></tr>
    <tr>
      <td class="data2Col " colspan="2">Label bla bla</td></tr><tr><td class="data2Col " colspan="2"></td>
      <td></td>
    </tr>
    <tr>
      <td class="data2Col " colspan="2"><input type="text" name="j_id0:j_id2:j_id3:j_id14:j_id19" value="13000.0"></td>
    </tr>
    <tr>
      <td class="data2Col " colspan="2"></td>
      <td></td>
    </tr>
    <tr>
      <td class="data2Col " colspan="2"><input type="text" name="j_id0:j_id2:j_id3:j_id14:j_id21"></td></tr><tr><td class="data2Col  last " colspan="2"></td>
  </tr>
</tbody></table>

 corresponding to :

<table border="1" width="100%">
  <tr>
    <td colspan="2" width="60%">Desc</td>
    <td colspan="2" width="20%">Total</td>
    <td colspan="2" width="20%">Part</td>
  </tr>
     <tr>
    <td><apex:outputText >Label bla bla</apex:outputText></td>
     <td><apex:inputText value="{!Building_Cost__c.CA1a_Real_Rent_Total__c}" label="" /></td>
    <td><apex:inputText value="{!Building_Cost__c.CA1a_Real_Rent_Part__c}" label="" /></td>
     </tr>
</table>

 

rklaassenrklaassen

Apparantly the renderer is trying to merge the field with the table, because I also see a tbody tag out of nowhere...

I don't know how to solve this without trying it myself, but maybe this is a solution for you:

<apex:panelGrid columns="3" id="theGrid">
  
  <apex:outputText value="Desc" />
  <apex:outputText value="Total" />
  <apex:outputText value="Part" />
  
  <apex:outputText >Label bla bla</apex:outputText>
  <apex:inputText value="{!Building_Cost__c.CA1a_Real_Rent_Total__c}" />
  <apex:inputText value="{!Building_Cost__c.CA1a_Real_Rent_Part__c}" />

</apex:panelGrid>

 It will render a table the way you want it?

This was selected as the best answer
cedgcedg

perfect  :)

 

thanks a lot