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
Jure KotnikJure Kotnik 

error:unkown function (why return me error unkown function

public class prijava_controller 
{
    public String idDel                 {get;set;}
    public list<Student__c> lista         {get;set;}
    
    public prijava_controller(ApexPages.StandardController controller){
       
        query();
        lista = new list<Student__c>();
  
    }

      public void deleterow()
      {
          String myId = System.currentPageReference().getParameters().get('rowId');  
 
                for(Integer i=0; i<lista.size(); i++) 
                {
                    Student__c c = lista[i];
                    if (c.Id == myId) 
                    {
                      lista.remove(i); // remove item only from list for avoid dispaly this item on vf page
                      // delete(c); - delete record from database
                      break;
                        }
                 }  

          
           }


apex:
                <apex:repeat value="{!lista}" var="s">      
                                                    
                    <TR>
                        
                        <TD>
                       <apex:commandButton  value="{!deleterow(s.Id)}" styleClass="delete">
                        <apex:param name ="rowId" value="{!deleterow(s.Id)}"/>
                        </apex:commandButton> 

                        </TD>

User-added image
Shiva RajendranShiva Rajendran
Hi Jure ,
I noticed few errors in your code for now
1. c.Id == myId  // replace it by c.Id == Id.valueOf(myId);


Also in                        <apex:commandButton  value="{!deleterow(s.Id)}" styleClass="delete">
// value is only for displaying name on the button . Use action ="{!deleterow}" this will be the function name getting called

Let me know if things worked.Else please do provide the error with code line to help you better.
Thanks and Regards,
Shiva RV
 
Anjum Attar 26Anjum Attar 26
Tryout this :
<apex:commandButton  action="{!deleterow}" styleClass="delete">
<apex:param name ="rowId" value="{!s.id}"/>
</apex:commandButton> 
Shiva RajendranShiva Rajendran
Hi Jure,

public class prijava_controller 
{
    public String idToDel                 {get;set;}

public void deleterow()
      {
      //    String myId = System.currentPageReference().getParameters().get('rowId');  
 
                for(Integer i=0; i<lista.size(); i++) 
                {
                    Student__c c = lista[i];
                    if (c.Id == idToDel) 
                    {
                      lista.remove(i); // remove item only from list for avoid dispaly this item on vf page
                      // delete(c); - delete record from database
                      break;
                        }
                 }  

          
           }

 line:39-->                       <apex:param name ="rowId" value="{!s.id}" assignTo="{!variableInApex}"/> // it should be variable name in apex class

Also replace <apex:outputText>
   <TD><apex:outputText value="{!s.Ime__c}" /></TD>
                       <TD><apex:outputtext value="{!s.Priimek__c}" /></TD>
                       <TD><apex:outputtext value="{!s.Naziv_fakultete__c}" /></TD>
by  <apex:outputField>

Let me know if you need any further help . If possible provide me the requirement wanted as well to help you better.

Thanks and Regards,
Shiva RV

 
Anjum Attar 26Anjum Attar 26
Use following code it is working:
VF Page :
<apex:page standardController="Student__c" extensions="prijava_controller" >
    <apex:form id="komplet">
        <!--
        <apex:actionFunction name="deleter" action="{!deleterow}">
            <apex:param name="rowId" value=""/>
        </apex:actionFunction>
        -->
        <apex:pageBlock title="Vnos študenta" id="vnos">   
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Student__c.Ime__c }" /> 
                <apex:inputField value="{!Student__c.Priimek__c}" />  
                <apex:inputField value="{!Student__c.Naziv_fakultete__c}" />   
                <apex:inputField value="{!Student__c.Tip_studija__c}">
                     <apex:actionSupport event="onchange" rerender="checkbox" />
                </apex:inputField>  
                <apex:inputCheckbox value="{!Student__c.Samoplacniki__c}"
                    disabled="{!if(Student__c.Tip_studija__c != 'izredni', true, false)}" 
                    id="checkbox"
                />                
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Submit" reRender="vnos" />
            </apex:pageBlockButtons> &nbsp;
            <table style="width:100%" border="1px">
                <thead>
                    <tr>
                        <td></td>
                        <td><b>Ime</b></td>
                        <td><b>Priimek</b></td>
                        <td><b>Naziv</b></td>
                        <td><b>Tip</b></td>
                        <td><b>Samoplačniki</b></td>
                    </tr>
                </thead>
                <tbody>
                    <apex:repeat value="{!lista}" var="s">                                    
                        <TR>
                           <TD>
                               <apex:commandButton value="delete" action="{!deleterow}" styleClass="delete" reRender="komplet">
                                   <apex:param name="rowId" value="{!s.Id}" assignTo="{!rowId}"/>
                               </apex:commandButton>
                               <apex:outputText value="{!s.Id}" />
                           </TD>
                        <TD><apex:outputText value="{!s.Ime__c}" /></TD>
                        <TD><apex:outputtext value="{!s.Priimek__c}" /></TD>
                        <TD><apex:outputtext value="{!s.Naziv_fakultete__c}" /></TD>
                        <TD><apex:outputtext value="{!s.Tip_studija__c}" /></TD>
                        <TD><apex:outputtext value="{!s.Samoplacniki__c}" /></TD>
                        </TR>
                     </apex:repeat> 
                </tbody>
           </table>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller :
public class prijava_controller 
{
    // the variable being set from the commandbutton
    public String rowId {get; set;}
    public list<Student__c> lista {get; set;}
    public prijava_controller(ApexPages.StandardController controller){
        query();
        System.debug('>>>lista1 :' + lista );
        
    }
    public pageReference deleterow() {
        System.debug('>>>rowId :' + rowId);
        String myId = this.rowId;
        System.debug('>>>myId :' + myId);
        //System.debug('>>>Id.valueOf(myId) :' + Id.valueOf(myId));
        for(Integer i=0; i<lista.size(); i++) {
            Student__c c = new Student__c ();
            c.Id = lista[i].Id;
            if (c.Id == Id.valueOf(myId)) {
                lista.remove(i); // remove item only from list for avoid dispaly this item on vf page
                // delete(c); - delete record from database
                break;
            }
        }
        return null;       
    }
    public void query() {
        lista = new list<Student__c>();
        lista = [select Id, Ime__c, Priimek__c, Naziv_fakultete__c, Tip_studija__c, Samoplacniki__c from student__c];
        System.debug('>>>lista :' + lista );   
    }
}
Anjum Attar 26Anjum Attar 26
In above code checkout query function and reRender and assignTo attribute on commandbutton.
As you are not deleting student records from database hence everytime when page get load it will show all records present in your org.
Shiva RajendranShiva Rajendran
Hi Jure Kotnik

First of all Anjum ,appologies for editing your code. I made few changes including outputField and custom get method , hope this will work fine.

Use following code it is working:
VF Page :
<apex:page standardController="Student__c" extensions="prijava_controller" >
    <apex:form id="komplet">
        <!--
        <apex:actionFunction name="deleter" action="{!deleterow}">
            <apex:param name="rowId" value=""/>
        </apex:actionFunction>
        -->
        <apex:pageBlock title="Vnos študenta" id="vnos">   
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Student__c.Ime__c }" /> 
                <apex:inputField value="{!Student__c.Priimek__c}" />  
                <apex:inputField value="{!Student__c.Naziv_fakultete__c}" />   
                <apex:inputField value="{!Student__c.Tip_studija__c}">
                     <apex:actionSupport event="onchange" rerender="checkbox" />
                </apex:inputField>  
                <apex:inputCheckbox value="{!Student__c.Samoplacniki__c}"
                    disabled="{!if(Student__c.Tip_studija__c != 'izredni', true, false)}" 
                    id="checkbox"
                />                
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Submit" reRender="vnos" />
            </apex:pageBlockButtons> &nbsp;
            <table style="width:100%" border="1px">
                <thead>
                    <tr>
                        <td></td>
                        <td><b>Ime</b></td>
                        <td><b>Priimek</b></td>
                        <td><b>Naziv</b></td>
                        <td><b>Tip</b></td>
                        <td><b>Samoplačniki</b></td>
                    </tr>
                </thead>
                <tbody>
<apex:outputPanel id="komplet">
                    <apex:repeat value="{!lista}" var="s">                                    
                        <TR>
                           <TD>
                               <apex:commandButton value="delete" action="{!deleterow}" styleClass="delete" reRender="komplet">
                                   <apex:param name="rowId" value="{!s.Id}" assignTo="{!rowId}"/>
                               </apex:commandButton>
                               <apex:outputText value="{!s.Id}" />
                           </TD>
                        <TD><apex:outputField value="{!s.Ime__c}" /></TD>
                        <TD><apex:outputField value="{!s.Priimek__c}" /></TD>
                        <TD><apex:outputField value="{!s.Naziv_fakultete__c}" /></TD>
                        <TD><apex:outputField value="{!s.Tip_studija__c}" /></TD>
                        <TD><apex:outputField value="{!s.Samoplacniki__c}" /></TD>
                        </TR>
                     </apex:repeat> 
</apex:outputPanel>
                </tbody>
           </table>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller :
public class prijava_controller 
{
    // the variable being set from the commandbutton
    public String rowId {get; set;}
    public list<Student__c> lista { set;}

public List<Student__c> getLista()
{
 System.debug('>>>lista :' + lista );   
if(lista==null)
{
        lista = [select Id, Ime__c, Priimek__c, Naziv_fakultete__c, Tip_studija__c, Samoplacniki__c from student__c];
 }
return
lista;     
    }

}
    public prijava_controller(ApexPages.StandardController controller){
        
        System.debug('>>>lista1 :' + lista );
        
    }
    public pageReference deleterow() {
        System.debug('>>>rowId :' + rowId);
        String myId = this.rowId;
        System.debug('>>>myId :' + myId);
        //System.debug('>>>Id.valueOf(myId) :' + Id.valueOf(myId));
        for(Integer i=0; i<lista.size(); i++) {
            Student__c c = new Student__c ();
            c.Id = lista[i].Id;
            if (c.Id == Id.valueOf(myId)) {
                lista.remove(i); // remove item only from list for avoid dispaly this item on vf page
                // delete(c); - delete record from database
                break;
            }
        }
        return null;       
    }
  
}



Let me know if this code work fine.
Thanks and Regards,
Shiva RV
 
Anjum Attar 26Anjum Attar 26
Hey Jure Kotnik,
Hii. 
Please make sure that you mark it as solved if my solution helped you and please like the answer. 

Thanks
Anjum Attar26.