+ Start a Discussion
Rakesh KumarRakesh Kumar 

How to display blank table's td tag ?

Hi all,

 

I want to add bulk values in to query list. That query list have one child list.

 

Code:

 

 queryStr = 'SELECT Field1,Field2, Id, RecordTypeId
                                   (

                                  SELECT childField1,chieldField2,chieldField3
                                    FROM Patient_Survey_Child__r

                                    )
                                FROM Patient_Survey_Parent__c';

 

searchedRecord  =  Database.query(queryStr); 

 

 for(Patient_Survey_Parent__c pst:searchedRecord){
            Integer size = pst.Patient_Survey_Child__r.size();
            date mydate = date.parse('01/01/1900');
            if(size < 6){
                Patient_Survey_Child__c pstGt= new Patient_Survey_Child__c();
                for(Integer j=0;j < 6 - size; j++ ){

                    pstGt.childField1 = 'blank';
                    pstGt.childField2='blank';
                    pstGt.childField3= 'blank';
                }
                pst.add(pstGt); // Here i am getting casting error
            }
   }

 

How can i add value in to child object list?

If i will add it in to list then easy to iterate on my visualforce page as black table data(TD)

 

Please share you idea.

 

Thanks in advance

Best Answer chosen by Admin (Salesforce Developers) 
Rakesh KumarRakesh Kumar

 

Its easy to solve my problem.

 

Code sample

 

<apex;outputpanel rendered="{!IF(ChildObject__r.size = 0,True,False)}">

<td></td>

<td></td>

<td></td>

<td></td>

</apex;outputpanel>

 

All Answers

Gunners_23Gunners_23

As per the code it seems pst is not even list and its the instance of parent object for which you're trying to add the child object which doesn't make any sense. Please clarify what is the exact thing you are trying to do

 

Thanks,

Rakesh KumarRakesh Kumar

Actually i want to display all records of parent and child object value in a single table row using  single query.

 

as per as my soql query i have child and parent object. after search result  i am getting child rows records 1 to 5.if child rows has all 1 to 5 rows then table display is good. but when child rows record has only one record then my table design is get destort. So i want to display all table td even it has one child row or more than one row.

 

visual force code

<table>

    <apex:repeat value="{!searchRecords}"  var="psl">

<tr>

                  <td   >{!psl.Field1}                  </td>
                    <td   >{!psl.Field2}                  </td>
                    <td   >{!psl.Field3}                  </td>
                    <apex:repeat value="{!psl.Patient_Survey_Child__r}" var="trends">
                         <td >{!trends.ChildField1}          </td>
                        <td >{!trends.ChildField2}          </td>
                        <td >{!trends.ChildField3}          </td>                     
                    </apex:repeat>

</tr>

</apex:repeat>

</table>

if blue color child object has 1 record then it iterate onetime but i would like to iterate it upto 4 times out of 5.

 

if my explanation is not make sense then i will put code sample.

 

rakesh

Rakesh KumarRakesh Kumar

 

Its easy to solve my problem.

 

Code sample

 

<apex;outputpanel rendered="{!IF(ChildObject__r.size = 0,True,False)}">

<td></td>

<td></td>

<td></td>

<td></td>

</apex;outputpanel>

 

This was selected as the best answer