You need to sign in to do that
Don't have an account?
Jure 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>
{
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>
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
<apex:commandButton action="{!deleterow}" styleClass="delete">
<apex:param name ="rowId" value="{!s.id}"/>
</apex:commandButton>
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
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>
<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 );
}
}
As you are not deleting student records from database hence everytime when page get load it will show all records present in your org.
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 :
Controller :
Let me know if this code work fine.
Thanks and Regards,
Shiva RV
Hii.
Please make sure that you mark it as solved if my solution helped you and please like the answer.
Thanks
Anjum Attar26.