+ Start a Discussion
KPGUPTAKPGUPTA 

Urgent------- how to create and save grid view atructure at visual force

 

  hello,
Actually i want to create a result document. in which i have to make a grid structure like 
student name/subjects            sub1                  sub2                       sub3            
studentname1                  text field(marks)       text field(marks)    text field(marks)
studentname2                 text field(marks)       text field(marks)     text field(marks)
student name3              text field(marks)        text field(marks)     text field(marks)
.
.
.


Now here subjects are coming from one custom object and student names are coming from other objects and marks will be enter by current object.

If any body know how to implement this plsss reply soon i need this urgently....

 

SidzSidz

Hi Gupta,

Here is wat you can do

Lets say we have two lists

List<Subject> subjects,List<Student> students;

now List<List<grid>> gridlist has to be populated.

 

in vf page you can access it as

<apex:datalist value="{!gridlist}" var="grid">

<apex:datalist value="{!grid}" var="gridvar">

{!gridvar}

 

try this.

hope it hepls

thanks,

sid

 

KPGUPTAKPGUPTA

Thanx for your reply..

bt in student list we fetch student namefrom student object in subject list we fetch subject names from subject objects 

bt in gridlist what we have to do??? can you please clear this more and how to save it later on if you can help thi than i shall be very thank ful to you...

SidzSidz

Hi Gupta,

Sorry to confuse you with the nested list idea.

you can simply loop through both the lists in vf page

<table>

<tr>

<td>StudentName/Subjects</td>

<apex:repeat value="{!subjects}" var="subject">

<td>

{!subject}

</td>

</apex:repeat>

</tr>

<tr>

<apex:repeat value="{!students}" var="student">

<td>

{!student}

</td>

<!-- now the text boxes related to each subject are to be populated -->

<apex:repeat value="{!subjects}" var="subject">

<td>

<input type="text" name="{!student}:{!subject}" value="" />

</td>

</apex:repeat>

</tr>

</apex:repeat>

</table>

 

In the controller we can access the values of the marks for each subject using

for(Student st:students)

{

for(Subject sb:subjects)

{

ApexPages.currentPage().getParameters().get(''+st+':'+sb);

}

}

 

hope it helps,

Sidz

KPGUPTAKPGUPTA

Sorry SId it will not work ... i send u my code 

apex class==========

public class ExaminationSetup 
{
  
  
    public void go()
    {
        citylist.clear();
        options.clear();
        activitylist.clear();
        stuMarks.clear();
        try
        {               
            class1 = examMarks.Class1__c;
            section = examMarks.Examination_Type__c;
            date1= examMarks.Date__c;
            
                examdetail = [Select ID, Student_Name__c FROM Examination_Setup__c];
                subjectlist =[SELECT SubjectId__r.Name,ClassId__c,Marks__c FROM SubjectClassRole__c WHERE (ClassId__c =:class1) AND (SubjectId__r.Name<>NULL)];
                if(class1!=null)
                { 
                    citylist = [Select Id,Name, Student_Name__c,Class_new__c FROM Student_Profile__c WHERE (Class_new__c=:class1) ORDER BY Student_Name__c ASC];
                    for(Student_Profile__c sku:citylist)
                    {
                        Examination_Setup__c sp1=new Examination_Setup__c();
                        sp1.Student_Name__c=sku.Name + ' ' + sku.Student_Name__c;
                        sp1.StudentID__c=sku.Name;
                        activitylist.add(sp1);
                    } 
                    for(SubjectClassRole__c subject : subjectlist)
                    {
                        Examination_Setup__c subjectdata=new Examination_Setup__c();
                        subjectdata.Subject__c=subject.SubjectId__r.Name;
                        subjectdata.Marks__c=subject.Marks__c;
                        subjectdata.Class1__c=subject.ClassId__c;
                        subjectdata.Student_Name__c=citylist[0].Student_Name__c;
                        system.debug('jawakaan de marksssssssssss' + subjectdata.Student_Name__c);
                        stuMarks.add(subjectdata);
                   }
               }
            }      
              public List<SelectOption> getactivitynames()    
              {        
                  return options;    
              }
              public List<Examination_Setup__c> getRecords() 
              {   
                  return activitylist;
              }
              public List<Examination_Setup__c> getSubjects() 
              {   
                  return stuMarks; 
              }
              public void setActivity(String activity)     
              {        
                  this.activity = activity;        
                  String section1=this.activity;
              }
              public String getActivity()     
              {        
                  return activity;    
              } 
 
        
         public PageReference save()
         {
         try  
         {  
            saveclass=act.Class1__c;
            saveexam=act.Examination_Type__c;
           
            insert stuMarks;
        }         
       
    }
        
}

 

 

 

=====================Visual Force page============================================

 

<table border="1" align="center">

 

    <tr>

       <td>

 

        </td>

        <apex:repeat value="{!Subjects}" id="repeat1" var="item">

        <td>

            <center><b><apex:outputField value="{!item.Subject__c}" id="theValue"/></b></center>

        </td>

        </apex:repeat>

    </tr>

    <apex:repeat value="{!Records}" id="repeat2" var="pitem">

    <tr>

        <td><center><b><apex:outputField value="{!pitem.Student_Name__c}" id="theValue"/></b></center></td>

 

        <apex:repeat value="{!Subjects}" id="repeat3" var="item">

        <td>

            <center><b><apex:inputField value="{!item.Marks__c}" id="theValue"/></b></center>

        </td>

         </apex:repeat>

     </tr>

      </apex:repeat>

 

 

</table>    

 

My objects are student profile from which i fetch student names, 2nd object is subject from where i fetch subject names and my current object is examination setup . 

 

Student name/subjects                         sub1                    sub2                           sub3..........

sname1                                      inputfield(marks)      inputfield(marks)    inputfield(marks)

sname2                                     inputfield(marks)        inputfield(marks)   inputfield(marks)

 

 

this thing which i cant do is i dnt knw how to locate the marks with suject and sname while saving 

 

 

please send me the correct code for this.....

 

SidzSidz

as i suggested do not use apex:input field to send your data

use a html input  text

there you can submit your form without binding it to your backend.

that can be accessed via ApexPages.currentPage.getParameters().get('the parameter name');

 

you can name the parameter in this fashion

studentId:subjectID which will be a unique one for each student and subject

 

hope this helps,

sid

KPGUPTAKPGUPTA

thanx for your replies... but i still have aproblem while saving the records. when i save the record of 3 students than it will just ave the record of 1st student not ol. that is my main problem..

and i dont find this solution thats why i send you my code .I already display my record in matrix form i got a problem while saving it.... if you can help me regarding this than i will be very thank ful to you..