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
deepu.sandeepdeepu.sandeep 

Table with 4 rows and 3 columns

Hi There,

                i wrote a code like dis

 

------ vf page----------

 

<apex:page controller="clscontact" >

  <apex:pageBlock >

      <apex:pageBlockTable value="{!con}" rows="3" columns="4" var="cc">

      <apex:column style="width:20px;"  ><apex:facet name="header">Name</apex:facet> {!cc.name}</apex:column>

        <Apex:column style="width:50px;"  ><apex:facet name="header">Email</apex:facet> {!cc.email}</apex:column>

          <Apex:column ><apex:facet name="header">Phone</apex:facet> {!cc.phone}</apex:column>

              <Apex:column ><apex:facet name="header">Account </apex:facet> {!cc.account.name}</apex:column>

      </apex:pageBlockTable>

 

  </apex:pageBlock>

</apex:page>

 

------------- Apex controller ----------

 

public class clscontact

{

public list<contact>con{get;set;}

public clscontact()

{

    con=[select name,email,phone,account.name from contact];

}

 

 

}

 

 

i am getting 4 cols and 3 rows but i am unable to enter a value in rows.

how can i enter a value in rows anyone suggest me...

SeAlVaSeAlVa

I'm sorry, but I don't get what you are asking.

 

What do you mean with enterning a value ?

 

Display the info as input?

Display plain text that you want?

 

 

deepu.sandeepdeepu.sandeep

Hi,

     I need a table with 4 columns and 3 rows in a visualforce view page and then ineed to enter a values in table rows.

tell me how can i do that..

SeAlVaSeAlVa

hard-coded values or values from an object?

deepu.sandeepdeepu.sandeep

Hi,

          sorry i didn't get u wat u said but , i need to manually enter the data in the vf page in table....

 

SeAlVaSeAlVa

Take this VF code

 

<apex:page controller="clscontact" >
  <apex:form >
    <apex:pageBlock title="A">
      <apex:pageBlockTable value="{!con}" rows="3" columns="4" var="cc">
        <apex:column style="width:20px;"  >
          <apex:facet name="header">
            Name
          </apex:facet>
          <apex:inputField value="{!cc.name}"/>
        </apex:column>
        <Apex:column style="width:50px;"  >
          <apex:facet name="header">
            Email
          </apex:facet>
          <apex:inputField value="{!cc.email}"/>
        </apex:column>
        <Apex:column >
          <apex:facet name="header">
            Phone
          </apex:facet>
          <apex:inputField value="{!cc.phone}"/>
        </apex:column>
        <Apex:column >
          <apex:facet name="header">
            Account 
          </apex:facet>
          <apex:inputField value="{!cc.account.name}"/>
        </apex:column>
      </apex:pageBlockTable>
    </apex:pageBlock>
    <apex:pageBlock title="B">
      <apex:pageBlockTable value="{!outputs}" rows="3" columns="4" var="output">
        <apex:column style="width:20px;" headerValue="Name" value="{!output['f1']}"/>
        <Apex:column style="width:50px;" headerValue="Email" value="{!output['f2']}"/>
        <apex:column headerValue="Phone" value="{!output['f3']}"/>
        <apex:column headerValue="Account" value="{!output['f4']}"/>
      </apex:pageBlockTable>
    </apex:pageBlock>
  </apex:form>
</apex:page>

 Controller

public class clscontact{
  public list<contact>con{get;set;}
  public list<Map<String, String>> outputs = new List<Map<String,String>>{new Map<String,String>{'f1'=>'a','f2'=>'b','f3'=>'c','f4'=>'d'},new Map<String,String>{'f1'=>'e','f2'=>'f','f3'=>'g','f4'=>'h'},new Map<String,String>{'f1'=>'i','f2'=>'j','f3'=>'k','f4'=>'l'}};
  public list<Map<String,String>> getOutputs(){return outputs;}

  public clscontact(){
    con=[select name,email,phone,account.name from contact];
  }
}

 And tell me if either 'A' or 'B' is close to what you are looking for.

 

Regards.

deepu.sandeepdeepu.sandeep

k its showing rows with manual entry of data but ,what ever the values i am entering in rows are not binding to database fields.i.e in record its showing noting in that row values.

How can i do that. do i need to create 3 fields in object like name1,name2,name3.

suggest me.