• ktdsm
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies

I am populating advanceDataGrid (Flex 3) from salesforce query. I want to show parent-child relationship in the grid.

The problem is that, when i am iterating the queryresult object in the for loop and dumping in the arraycollection object, it only adds those records into the Array , that has chidren in it.Otherwise , it is exiting the loop.

for example , if first record has a child then, it adds it into the array collection object  and goes to second iteration i.e i=1.When it sees that second parent record doesn't have any child in it then it exist the loop and bind the advance datagrid with only one record.Although , the queryresult has 8 parent rows in it.
When i apply this check around the addition process of records into the arraycollection object :

 

if(qr.records[k].RecS__Features__r != null){

}

 

After applying the above if {} check ,it starts adding the rows in it but only those rows that has Children.But it didn't show the children records in the Grid.Now it shows only Parent Records without children .

I need to display those   Records that don't have any Children as well as those that have Children associated to it in the advance datagrid.So that , the rows with children records , user can expand the node to see its children.With rows no folder sign , the user will come to know that this row doesn't have any child rows.

Here is my code :

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"

xmlns:salesforce="http://www.salesforce.com/" applicationComplete="init()"

themeColor="#E7ECEF" cornerRadius="3">

 

<salesforce:Connection id="force" />

 

<mx:Script >

<![CDATA[

 //import statements here

 

//Declaration

[Bindable]

private var objSprint:Object;

[Bindable]private var gdSprint:ArrayCollection=new ArrayCollection();
[Bindable]

private var tempSprint:ArrayCollection=new ArrayCollection();

 

 

 //Code here

private function init():void

{

var lr:LoginRequest = new LoginRequest(); lr.username = "salesforce username";
lr.password =
"************";
lr.callback = new AsyncResponder(loginHandler);

force.login(lr);

 

lr.callback = new AsyncResponder(populateGrid);

force.login(lr);

}

 

 

private function loginHandler(result:LoginResult):void

{

 

force.query("Select id ,Name,RecS__Product_Name__c from RecS__Product_Backlog__c ",

new AsyncResponder(function(result:QueryResult):void

{

 

 

ddlBack.addItemAt("All",0);

 

for(var i : int =0 ; i < result.records.length;i++){

 

ddlBack.addItem({Id:result.records[i].Id,RecS__Product_Name__c :result.records[i].RecS__Product_Name__c,SObjectField:result.records[i]});

 

 

}

 

}));

 

}

 

private function populateGrid(result:LoginResult):void{

 

force.query("Select r.Id, r.Name,r.RecS__Sprint_Name__c, r.RecS__Start_Date__c, r.RecS__Status__c, (Select Id,"+

" Name, "RecS__Feature_Name__c, RecS__Product_Backlog__c,  RecS__Sprint__c, RecS__Start_Date__c  From "+ 

"RecS__Features__r where RecS__Product_Backlog__c =null "+

" and RecS__Sprint__c <> null) from RecS__Sprint__c r",new AsyncResponder(function(qrSp:QueryResult):void

{

gdSprint=qrSp.records;

 

for(var k:int =0 ; k < qrSp.records.length ; k++)

{

lbl.text+= qrSp.records[k].RecS__Features__r.records.length; 

if(qrSp.records[k].RecS__Features__r != null){
tempSprint.addItem({RecS__Sprint_Name__c :qrSp.records[k].RecS__Sprint_Name__c,

Id:qrSp.records[k].Id,Children:qrSp.records[k].RecS__Features__r.records,SObjectField:qrSp.records[k]});
}
}

objSprint =Object(tempSprint);

 gridSprint.dataProvider=tempSprint; 

 

}));

}

  

]]>

</mx:Script>
<mx:Panel title="Sprint Items"  

paddingTop="10" paddingLeft="10" paddingRight="10" height="554" width="505" x="416" y="44">

<mx:AdvancedDataGrid id="gridSprint" designViewDataType="tree" width="419" height="451">

<mx:dataProvider> 

<mx:HierarchicalData source="{objSprint}" childrenField="Children" > </mx:HierarchicalData>

</mx:dataProvider> 

<mx:columns>

<mx:AdvancedDataGridColumn headerText="Sprint" fontStyle="normal" fontWeight="bold" dataField="RecS__Sprint_Name__c">

 </mx:AdvancedDataGridColumn> <mx:AdvancedDataGridColumn headerText="Feature" dataField="RecS__Feature_Name__c"/>

<mx:AdvancedDataGridColumn headerText="St. Date" dataField="RecS__Start_Date__c"/>

<mx:AdvancedDataGridColumn headerText="Id" visible="false" dataField="Id"/>

</mx:columns> 

</mx:AdvancedDataGrid>

</mx:Panel>

</mx:Application>

 

Please can any one help me ... it is driving me crazy ....

  • October 13, 2009
  • Like
  • 0

Hi,

 

I have a button on a related list . This button is calling another button that is on parent object and is hidden.This hidden button calls a S- Control.

 

Instead of hardcoding the id of hidden button in the javacript code to make a call to it , i want to get the hidden button id dynamically when the user hits the related list button(javascript is written).

 

 

I really need it very urgent !!!

  • June 07, 2009
  • Like
  • 0

Hi,

 

I have a button on a related list . This button is calling another button that is on parent object and is hidden.This hidden button calls a S- Control.

 

Instead of hardcoding the id of hidden button in the javacript code to make a call to it , i want to get the hidden button id dynamically when the user hits the related list button(javascript is written).

 

 

I really need it very urgent !!!

 

 

  • June 03, 2009
  • Like
  • 0

Hi, I am trying to create a form using extjs and adding a save button to it which will save the data into salesfroce database.But its not working for me...

Below is the VF code  and the controller code.

 

 

<apex:page controller="EmployeeData" sidebar="false">

 

<link rel="Stylesheet" type="text/css" href="{!$Resource.ExtJS}/resources/css/ext-all.css" />

<script type="text/javascript" src="{!$Resource.ExtJS}/adapter/ext/ext-base.js"></script>

<script type="text/javascript" src="{!$Resource.ExtJS}/ext-all.js"></script>

 

<script type="text/javascript">

Ext.onReady(function(){

var employee_form = new Ext.FormPanel({

labelWidth: 75,

url: "{!save}",

title:'Employee Details',

frame:true,

width:500,

items: [{xtype: 'textfield', fieldLabel: 'Employee Name',name: 'empName'},

{xtype: 'textfield', fieldLabel: 'Employee Code',name: 'empNo'},

{xtype: 'textfield', fieldLabel: 'Designation',name: 'desig'}],

buttons: [{text: 'Save'}]

});

 

Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

var myDataString = 'var myData = [ ';

<apex:repeat value="{!employeeData1}" var="e" id="ContactRepeat">

myDataString += "['{!e.Employee_Code__c}','{!e.Employee_Name__c}','{!e.Designation__c}'],";

</apex:repeat>

myDataString += "['','',''] ];";

eval(myDataString);

var store = new

Ext.data.SimpleStore({fields:[{name:'Employee_Code__c'},{name:'Employee_Name__c'},{name:'Designation__c'}]}); store.loadData(myData);

 

// CREATE THE GRID

 

var grid = new Ext.grid.GridPanel({store: store, columns: [

{id: 'Employee_Code__c', header: "Employee Code", width:00, sortable:true,frame:true, dataIndex: 'Employee_Code__c'},

{id: 'Employee_Name__c', header: "Employee Name", width: 150, sortable: true,frame:true, dataIndex: 'Employee_Name__c'},

{id: 'Designation__c', header: "Designation", width: 150, sortable: true,frame:true, dataIndex: 'Designation__c'} ],stripeRows:true,frame:true, autoExpandColumn: 'Employee_Code__c', height: 230, width: 500, title: 'MY EXT JS EMPLOYEE\'S CONTACT LIST'});

employee_form.render('employeeDetails');

grid.render('myContactList-grid');

grid.getSelectionModel().selectFirstRow();

});

</script>

 

<div id="employeeDetails"></div>

<div id="myContactList-grid"></div>

 

</apex:page>

 Controller code is - 

 

 

public class EmployeeData {

List<Employee__c> emp;

String employeeName;

public List<Employee__c> getEmployeeData1()

{

return emp = [select Employee_Code__c,Employee_Name__c, Designation__c from Employee__c];

}

public String getEmployeeName()

{

return employeeName;

}

public PageReference save()

{

//Insert code

return null;

}

}

 

 The save button is not working and i am getting errror -

 

 

Save error: Unknown property 'EmployeeData.save' Employee.page TestProject/src/pages

 

 

 

 

Message Edited by 1986anuj on 03-09-2009 06:11 AM

Please help me on calling a JavaScript in VF page

 

I tried below options

 

 

 

<script type="text/javascript" src="{!URLFOR($Resource.myscript,'/test.js')}"/>

 


 

 

where 'test' is a javascript file saves in zip file named myscript in Static resources

 

 

<apex:includeScript value="{!$Resource.tstres}"/>



<script type="text/javascript" src="{!$Resource.tstres}"/>

 

where tstres is javascript file saved directly in static resources.

 

The script is 

 

<script type="text/javascript">
document.write("Hello World!")
</script>

 

 if I write the script directly in the page editor its printing Hello world.

But its not working with, includescript .

 

Its not showing any error.

 

Thanks in advance