You need to sign in to do that
Don't have an account?
Chanagan Sakulteera
Use radio button but it cannot save.
Hi all,
I use radio button in my visualforce page but it's not save.
I try apex:inputCheckbox or apex:inputField and actionsupport it's not working.
this is my visualforce page :
and this is my controller :
method onCheck() it not use, if i use <input type="radio" />
Thank you in advance.
I use radio button in my visualforce page but it's not save.
I try apex:inputCheckbox or apex:inputField and actionsupport it's not working.
this is my visualforce page :
<apex:page standardController="Quotation_Request__c" extensions="Select_MOQ_Extension" sidebar="false"> <p><apex:sectionHeader title="Select MOQ" subtitle="{!theQuote.Name}"/></p> <apex:form > <apex:pageBlock title="Quotation Request Line Item"> <apex:repeat value="{!lstQuoteLine}" var="items"> <p> <apex:pageBlock title="{!items.Name}"> <p> <apex:pageBlockSection title="Quotation Request Line Item Information" collapsible="false"> <apex:outputField value="{!items.S_J_Code__c}"/> <apex:outputField value="{!items.Trade_Name__c}"/> <apex:outputField value="{!items.Raw_Material_Group_Function__c}"/> <apex:outputText ></apex:outputText> <apex:outputField value="{!items.Unit_Price__c}"/> <apex:outputField value="{!items.Quantity__c}"/> </apex:pageBlockSection> </p> <apex:pageBlockSection title="Quotation MOQ Information" collapsible="false" columns="1"/> <table id="QuoteMOQ" border="1" cellspacing="1" cellpadding="2" bordercolor="#eeeeee" width="30%" style="margin-left:20px"> <tr> <td style="background-color: #87CEEB;" align="center"></td> <td style="background-color: #87CEEB;" align="center" ><b>Quantity</b></td> <td style="background-color: #87CEEB;" align="center"><b>Price</b></td> </tr> <apex:repeat value="{!lstQuoteMOQ}" var="item"> <apex:outputPanel rendered="{!if (items.Id == item.Quotation_Request_Line_Item__c, true, false)}"> <tr> <td align="center"> <input type="radio" name="{!item.Quotation_Request_Line_Item__c}" value="{!item.Selected__c}"/> <!-- <apex:inputCheckbox value="{!item.Selected__c}"> <apex:actionSupport action="{!onCheck}" event="onchange"> <apex:param assignTo="{!checkMOQ}" value="{!item.Id}" name="checkMOQ"/> <apex:param assignTo="{!checkQuoteLine}" value="{!item.Quotation_Request_Line_Item__c}" name="checkQuoteLine"/> </apex:actionSupport> </apex:inputCheckbox> --> </td> <td align="center">{!item.Quantity__c}</td> <td align="center">{!item.Price__c}</td> </tr> </apex:outputPanel> </apex:repeat> </table> </apex:pageBlock> </p> </apex:repeat> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!onSave}"/> <apex:commandButton value="Cancel" action="{!Cancel}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
and this is my controller :
public with sharing class Select_MOQ_Extension { private String quoteId {get; set;} public Quotation_Request__c theQuote {get; set;} public List<Quotation_Request_Line_Item__c> lstQuoteLine {get; set;} public List<Quotation_MOQ__c> lstQuoteMOQ {get; set;} public String checkMOQ {get; set;} public String checkQuoteLine {get; set;} public Select_MOQ_Extension(ApexPages.StandardController controller) { quoteId = ApexPages.currentPage().getParameters().get('id'); theQuote = [select Id, Name from Quotation_Request__c where Id =: quoteId]; lstQuoteLine = [select Id, Quantity__c, Quotation_Request__c, Unit_Price__c, Raw_Material_Group_Function__c, S_J_Code__c, Trade_Name__c, Name from Quotation_Request_Line_Item__c where Quotation_Request__c =: theQuote.Id order by Name asc]; lstQuoteMOQ = new List<Quotation_MOQ__c>(); for (Quotation_Request_Line_Item__c quoteLine : lstQuoteLine) { for (Quotation_MOQ__c quoteMOQ : [select Id, Quantity__c, Quotation_Request_Line_Item__c, Price__c, Quotation_Request__c, Name, Selected__c from Quotation_MOQ__c where Quotation_Request_Line_Item__c =: quoteLine.Id]) { lstQuoteMOQ.add(quoteMOQ); } } } public void onCheck() { system.debug('checkMOQ : ' + checkMOQ); for (Quotation_MOQ__c quoteMOQ : lstQuoteMOQ) { if ((String)quoteMOQ.Id == checkMOQ) { quoteMOQ.Selected__c = true; //system.debug('quoteMOQ.Selected__c : ' + quoteMOQ.Selected__c); } else { quoteMOQ.Selected__c = false; } } } public PageReference onSave() { for (Quotation_MOQ__c quoteMOQ : lstQuoteMOQ) { system.debug('quoteMOQ.Selected__c : ' + quoteMOQ.Selected__c); if (quoteMOQ.Selected__c == true) { Quotation_Request_Line_Item__c quoteLine = [select Id, Unit_Price__c, Quantity__c from Quotation_Request_Line_Item__c where Id =: quoteMOQ.Quotation_Request_Line_Item__c]; quoteLine.Quantity__c = quoteMOQ.Quantity__c; quoteLine.Unit_Price__c = quoteMOQ.Price__c; upsert(quoteLine); } } upsert(lstQuoteMOQ); String url = '/'+theQuote.Id; PageReference pref = new PageReference(url); return null; } }
method onCheck() it not use, if i use <input type="radio" />
Thank you in advance.