<apex:page
standardController="Product__c" extensions="BarCodeCon"
sidebar="false">
<script>
function checkAll(cb)
{
var inputElem =
document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++)
{
if(inputElem[i].id.indexOf("checkedone")!=-1)
inputElem[i].checked = cb.checked;
}
}
</script>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Enter Product Details" >
<apex:inputField value="{!Obj.name}" />
<apex:inputField value="{!Obj.price__c}" />
<apex:inputField value="{!Obj.code__c}" />
<apex:commandButton value="save"
action="{!save}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockSection title="Product Details"
columns="100">
<apex:dataTable value="{!rec}" var="m"
columns="10" columnsWidth="20px" >
<!-- <apex:column >
<apex:facet
name="header">
<apex:inputCheckbox
>
<apex:actionSupport event="onclick"
action="{!selrec}" onsubmit="checkAll(this)"
rerender="Selected"/>
</apex:inputCheckbox>
</apex:facet>
<apex:inputCheckbox
id="Selected">
<apex:actionSupport event="onclick"
action="{!selrec}" rerender="Selected"/>
</apex:inputCheckbox>
</apex:column>-->
<apex:column
value="{!m.product.name}" />
<apex:column
value="{!m.product.price__c}" />
<apex:column
value="{!m.product.Barcode__c}" />
</apex:dataTable>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<!--<apex:commandButton
value="Convert" action="{!convert}"/>-->
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
public with sharing class BarCodeCon {
public BarCodeCon(ApexPages.StandardController
controller) {}
public string Obj{set;}
Product__c ob;
public Product__c getObj(){
ob=new Product__c();
return ob;
}
public void save(){
insert ob;
}
public string rec{set;}
List<Product__c> li;
public List<productwrapper> getrec(){
productList.clear();
for(product__c p:[select name,price__c,barcode__c from Product__c]){
productList.add(new productWrapper(p));
return productList;
}
return productList;
}
List<SelProduct__c> storeli=new List<SelProduct__c>();
public void convert(){
SelProduct__c s;
for(Product__c p:selectedproducts){
s=new SelProduct__c();
s.name=p.name;
// storeli.add(s);
}
insert s;
}
List<Product__c > selectedproducts = new List<Product__c
>();
List<productWrapper> productList = new
List<productWrapper>();
public PageReference selrec() {
//getselected
selectedproducts.clear();
for(productWrapper pwrapper : productList )
if(pwrapper.selected == true)
selectedproducts.add(pwrapper.product);
return null;
}
public class productWrapper{
public Product__c product{get; set;}
public Boolean selected {get; set;}
public productWrapper(Product__c b)
{
product= b;
selected= false;
}
}
}
No comments:
Post a Comment