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
ArunaAruna 

Reload or Refresh snecha (ExtJ3.0) table upon button click on visualforce page

Hi Guys,

 

I have a visual force page which display the  snecha(Extj3.0) table with one button bottom of the table .

 

When i click on the button it will create a contact, case and opens a newly create case window.

 

The table will display the create contact details if I do ctr+f5 .

 

But i need this value to be in the table when i click on button.

 

I means when i click on button snecha(extj3.0) table has to reload or refresh with newly create contact and opee a new window.

 

I was bale to open a newly created case window with the help of javascript. but I am unable to reload the data into the table.

 

 Can anyone suggest me how to solve this problem any help or code sample is much appreciated.

cloudmaniacloudmania

Could you post  your whole visualforce then it will be easier to help.

ArunaAruna

I am unable to send code .

 

It exceeding 20,000 charetcors .

 

could you please give em your email id so that i can send the code to your email id.

cwall_sfdccwall_sfdc

Try hooking your Ext table w/ a Visualforce Remoting function.

 

I believe you'd integrate with the table's backing datastore.  On row edit or data change event, post the change back to your Visualforce remoted method.  To load the table, you can call another remoted method to get the data when the page is read (Ext.onReady) or call the remoted method post-datastore creation.  You may also dynamically create an Ext model based on the data returned from the remoted method.  You'd then hand-off the model to the datastore and then feed the store with your data.

 

Hope that helps.

ArunaAruna

 

Hi,

 

I am not using any remote methods to get the data.

 

I am using apex controller which pull the data and push into the component.

 

I am unable to post the code, it exceeding characters, Could you please give me your email id so that i can post my code to you.

 

That will be very easy to figure it out what is the problem.

 

Thank you.

ArunaAruna
Here is the code Apex,class, Component and visulforce page
Component
<apex:component >
      <script>
     var priority;
     var accIdValue;
     var conIdValue;
     var firstNameValue;
     var lastNameValue;
     var emailValue;
         var contactRecordSelected;
     function contactPopupLink(){
        return '<a href=javascript&colon;contactPopup();>Contact</a>';
        }
    function contactPopup(){
         var newWin=null;
         var url=window.location.protocol+'//'+window.location.host+'/'+conIdValue;
         newWin=window.open(url, 'Popup','height=800,width=1000,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
         newWin.focus();
       }
    </script>
   <apex:attribute name="contactList" description="List of existing contacts" type="ContactsBean[]"/>
    <apex:outputPanel id="con_OP">
         <table id="abc" border="1" >
             <tr ><td>
             <div id="con-grid" height="100px" width="100%"></div>
            <script type="text/javascript">
             var sm = new Ext.grid.CheckboxSelectionModel({
             singleSelect: true,
             sortable: false,
             checkonly: true,
             hidden:false
             });
               function SalesforceFunction(){         
    var ConColumns = [{
                        id: "edit",
                        header: "Contact",
                        width: 80,
                        renderer:contactPopupLink,
                        dataIndex: "edit",
                        hideable:false
                    },
                        sm
                        ,
                        {
                           id: "accid",
                            header: "accId",
                            //sortable: true,
                            //filter: {},
                            width: 150,
                            dataIndex: "accidvalue",
                             hidden:true,
                        },
                        {
                           id: "id",
                            header: "Id",
                            width: 150,
                            dataIndex: "idvalue",
                             hidden:true,
                        },
                        {
                           id: "priority",
                            header: "priority",
                            sortable: true,
                            width: 150,
                            dataIndex: "priority",
                             hidden:true,
                        },
                        {
                           id: "firstname",
                            header: "FirstName",
                            sortable: true,
                            filter: {},
                            width: 150,
                            dataIndex: "firstname"
                        },
                        {
                            id: "lastname",
                            header: "LastName",
                            sortable: true,
                            filter: {},
                            width: 100,
                            dataIndex: "lastname"
                        },      
                               ];
            var stringCondition = function( c ){
                                    if ( Ext.isString( c ) && c != "" )
                                        return c.replace( "'", "" );
                                    else
                                        return c;
                                    };
            ConElements = "";
            <apex:repeat value="{!contactList}" var="con" id="conId">          
                ConElements += '["Contact",';
                ConElements += '"' + "Select"+'",';
                ConElements += '"' + stringCondition( "{!con.conAccId}" ) + '",';
                ConElements += '"' + stringCondition( "{!con.conId}" ) + '",';
                ConElements += '"' + stringCondition( "{!con.priority}" ) + '",';
                ConElements += '"' + stringCondition( "{!con.conFirstName}" ) + '",';
                ConElements += '"' + stringCondition( "{!con.conLastName}" ) + '",';
                ConElements += '"' + stringCondition("{!con.conEmailAddress}" ) + '",';
               + '"],';
            </apex:repeat>
        ConElements = "([" + ConElements.substr( 0, ConElements.length - 1 ) + "])";
            var ConData = eval( ConElements );
            var ConFields = [{name:'edit'},
                         {name: 'select'},
                          {name: 'accidvalue'},
                         {name: 'idvalue'},
                         {name: 'priority'},
                         {name:'firstname'} ,
                         {name:'lastname'},
                         {name:'email'},
            ];
            var ConRecord = [];
            for ( i = 0; i < ConFields.length; i++ ){
                // record field element.
                ConRecord.push( { name: ConFields[ i ].name, mapping: i } ); 
            }
            ConRecord = Ext.data.Record.create( ConRecord );
                    var ConReader = new Ext.data.ArrayReader( null, ConRecord );
                    var myPageSize2 = 10;
            var ConStore =new Ext.data.GroupingStore(
                                          {
                                            autoDestroy: true,
                                            reader: ConReader,
                                            sortInfo: { field: 'priority', direction: 'ASC' },
                                            groupOnSort: false,
                                                                                }
                                       );
                                             
            ConStore.loadData(ConData);
            var view2 = new Ext.grid.GroupingView({
                          groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
   });         
            var ConGrid = new Ext.grid.GridPanel({
                id:'quick-grind',
                store: ConStore,
                columns: ConColumns,
                autoscroll: true,
                height:300,
                width:1000,
                view:view2,
                renderTo: Ext.get('con-grid'),
                frame:true,
                plugins: ["filterrow"],
                sm: sm,
                listeners: {
                  cellclick :function(ConGrid,rowIndex,columnIndex,e)  {
                   var record = ConGrid.getStore().getAt(rowIndex);  // Get the Record
                    accIdValue=record.get('accidvalue');
                    conIdValue=record.get('idvalue');
                    firstNameValue=record.get('firstname');
                   priority=record.get('priority');
                    //alert("priority="+priority);
                    lastNameValue=record.get('lastname');
                    emailValue=record.get('email');
                                       }
                              
            }});
            if (( Ext.get('con-grid')) !== null){
                ConGrid.render('con-grid');
            }
            }
            </script>
             </td></tr>
         </table>
    </apex:outputPanel>
</apex:component>
Visulaforce Page 
<apex:page controller="controllername" sidebar="false" id="pid">
<center><apex:pageMessages /></cente>
<script>
function fnSaveWithCase(){
       saveWithCase(accIdValue,conIdValue,firstNameValue,lastNameValue,emailValue,contactRecordSelected);
 } 
<apex:form id="newCaseForm">
<script>
var newCaseId='{!newCaseObjectId}';
if(newCaseId!='' && newCaseId!=null){
        var url=window.location.protocol+'//'+window.location.host+'/'+newCaseId;
      newWin=window.open(url, 'Popup','height=800,width=1000,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
      newWin.focus();
  }
</script>
</apex:form>
    <apex:form id="fid">                      
            <apex:pageBlockSection title="Salesforce Contacts" collapsible="true" id="pbs6">           
            <apex:outputPanel id="CaseRecordTypePanel" >
                <apex:outputText value="Select Case Record Type" style="font-weight:bold;font-family: 'Arial', 'Helvetica', sans-serif;"/>&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:selectList value="{!CaseRecordTypeName}"  size="1" id="recordTypeSelected"  >
                   <apex:actionSupport event="onchange" action="{!onChange}"  reRender="CaseRecordTypePanel"/>
                   <apex:selectOptions value="{!CaseRecordType}"  />
                   </apex:selectList> 
            </apex:outputPanel>
                <br/><br/>
             <apex:outputPanel id="conResults" >
             <center><c:mdbContactDisplay_component contactList="{!ContactsList}" /></center>
               </apex:outputPanel> 
            </apex:pageBlockSection> 
   <apex:commandButton value=" Save with Case " title="Save Entire Page" onclick="javascript&colon;fnSaveWithCase(); return false;" >
                                  <apex:actionFunction name="saveWithCase" action="{!saveWithCase}" reRender="newCaseForm" >
                                <apex:param name="accId" value="" />
                                <apex:param name="conId" value="" />
                                  <apex:param name="firstName" value=""/>
                                <apex:param name="lastName" value="" />
                                <apex:param name="email" value="" />
                                <apex:param name="contactRecordSelected" value=""/>
                                </apex:actionFunction>
                                </apex:commandButton>
   </apex:pageBlock>
     <script>
    Ext.onReady(function(){
      SalesforceFunction();
    });
   </script>
  </apex:form>
</apex:page>
    list<Account> AccList=[select id,Name from Account where Name='Anonymous'];
    Id CRrecordtype=[select id ,Name from RecordType where Name=’some record'].id;
    Communication__c newComm;
    List<ContactsBean> conBeanList{get;set;}
    public String CaseRecordTypeName{get;set;}
Id caseRecId;   
    Case newCase;
    public string accId{get;set;}
    public string conId{get;set;}
    public string priorty{get;set;}
    public String firstName{get;set;}
    public String lastName{get;set;}
    public String email{get;set;}
       public String contactRecordSelectedValue{get;set;}
    public String newCaseObjectId{get;set;}
    //Call the SaveWithCase method
    public Pagereference saveWithCase(){
    accId = Apexpages.currentPage().getParameters().get('accId');
    conId = Apexpages.currentPage().getParameters().get('conId');
    firstName = Apexpages.currentPage().getParameters().get('firstName');
    lastName = Apexpages.currentPage().getParameters().get('lastName');
    email = Apexpages.currentPage().getParameters().get('email');
      contactRecordSelectedValue = Apexpages.currentPage().getParameters().get('contactRecordSelected');
       //get the CaseRecordTypeId
     if(caseRecId==null){
        system.debug('*** looking up caseRecId='+CaseRecordTypeName);
        caseRecId=[select id ,Name from RecordType where Name=:CaseRecordTypeName].id;
    }
          create_Contact_Case_Communication();
           return null;
    }
    public void create_Contact_Case_Communication(){
    Case newCaseObject= new Case();
    Boolean createContact=true;
                if(contactRecordSelectedValue!=null && contactRecordSelectedValue!='' && contactRecordSelectedValue=='true'){
                    newComm= createCommunication(firstName+lastName ,AccList.get(0).id,conId);
 
                newCaseObject=createCase(accId,conId, getAccLogComment(),newComm.id,caseRecId);
            }
                else{
                Contact newConatct=createContact();
                newComm= createCommunication(newConatct.FirstName + newConatct.LastName ,AccList.get(0).id,newConatct.id);
newCaseObject=createCase(AccList.get(0).id,newConatct.id,getAccLogComment(),newComm.id,caseRecId);
            }
            if(newCaseObject!=null){
                newCaseObjectId=newCaseObject.Id;
            }
    }
    public Contact createContact(){
    Contact newConact=new Contact(RecordTypeId=CRrecordtype,AccountId=AccList.get(0).id,FirstName=accSearchResult.FirstName,LastName=accSearchResult.LastName,Phone=accSearchResult.PhoneNumber,Email=accSearchResult.EmailAddress, );
    insert newConact;
    return newConact;
    }
   public Communication__c createCommunication(string name,Id accId,Id conId){
        Communication__c newComm = new Communication__c(Name = name+ '-' + 'Email',Account__c = accId,Contact__c = conId,Communication_Type__c = 'Other');
    insert newComm;
       return newComm;
   }
   public Case createCase(Id accId,Id conId, string description,Id comId,Id recId){
        list<Case> caseList=new list<Case>();
    Case newCase=new Case(AccountId = accId,ContactId =conId,Description =description,Initial_Communication__c=comId,Status = 'Open',RecordTypeId=recId,Type='Company Info',Call_Subject__c='Availability',Origin='Phone',Caller_Type__c='Consumer');
       insert newCase;  
    caseList.add(newCase); 
    return newCase;
   }  
   string sRecordTypeId ;
   string recname;
   public List<SelectOption> getCaseRecordType(){
        List<SelectOption> options = new List<SelectOption>();
        Schema.DescribeSObjectResult oSObjectResult = Case.SObjectType.getDescribe();
        list<RecordTypeInfo> oRecTypeInfos = oSObjectResult.getRecordTypeInfos();
        for (RecordTypeInfo oRecTypeInfo : oRecTypeInfos){
                        if (oRecTypeInfo.Available == true && oRecTypeInfo.Name!='Master'){
                sRecordTypeId = oRecTypeInfo.recordTypeId;
                             recname=oRecTypeInfo.Name;
                            options.add(new SelectOption(recname,recname));
            }
       }
        return options;
   }
    public void onChange(){
    string onChangeValue=CaseRecordTypeName;
    caseRecId=[select id ,Name from RecordType where Name=:CaseRecordTypeName].id;
     }
   list<Contact> listContact=new list<Contact>();
   public list<ContactsBean> getContactsList(){
    listContact=[SELECT Id,name,RecordTypeId,AccountId,FirstName,LastName,Phone,Email,MailingCity,MailingCountry,MailingPostalCode,MailingState,MailingStreet
                 FROM contact where Email=:accSearchResult.EmailAddress or Phone=:accSearchResult.PhoneNumber or LastName=:accSearchResult.LastName  or MailingPostalCode=:accSearchResult.address.zipCode ];        
    conBeanList = new List<ContactsBean>();
    for(Contact con :listContact){
        ContactsBean conBeanRecord = new ContactsBean();       
       conBeanRecord.CRrecordtypeId=con.RecordTypeId;
       conBeanRecord.conId = con.Id;
       conBeanRecord.conAccId = con.AccountId;
       conBeanRecord.conFirstName = con.FirstName;
       conBeanRecord.conLastName = con.LastName;
           conBeanRecord.conEmailAddress = con.Email;
            if(conBeanRecord.conEmailAddress==accSearchResult.EmailAddress.toLowerCase())
       conBeanRecord.priority=1;
       else if(conBeanRecord.conPhoneNumber==accSearchResult.PhoneNumber && conBeanRecord.conLastName==accSearchResult.LastName.toLowerCase()) 
        conBeanRecord.priority=2;
        else
         conBeanRecord.priority=3;
       conBeanList.add(conBeanRecord);
       }
       return conBeanList;
    }
 Bean Class
 public with sharing class ContactsBean {
        public Boolean isSelected{get;set;}
        public Boolean isEnabled{get;set;}
        public Id CRrecordtypeId{get;set;}
        public Integer priority{get;set;}
              public Id conId{get;set;}
        public Id conAccId{get;set;}
        public String conFirstName{get;set;}
        public String conLastName{get;set;}
}