Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow users to supply a fieldset instead of a hardcoded list of field…

…s to be used as columns
  • Loading branch information...
commit b3211fcd9612c6a1ee3ffb2573bd78ee22cece4c 1 parent 661ffcb
@jefftrull authored
Showing with 13 additions and 1 deletion.
  1. +13 −1 components/ExtJS4_Data_Grid_with_JSR.component
View
14 components/ExtJS4_Data_Grid_with_JSR.component
@@ -17,7 +17,8 @@ Copyright 2011 Jeff Trull <jetrull@sbcglobal.net>
<!-- A Visualforce component implementing an ExtJS4 grid backed by JS Remoting from a controller -->
<!-- Jeff Trull 8/10/2011 -->
<apex:attribute name="object" type="String" description="sObject to generate a grid for" required="true"/>
- <apex:attribute name="fields" type="String[]" description="list of fields to display" required="true"/>
+ <apex:attribute name="fields" type="String[]" description="list of fields to display" />
+ <apex:attribute name="fieldset" type="String" description="fieldset to display" />
<apex:attribute name="minimized" type="Boolean" description="whether to initially render the grid in minimized state" default="false"/>
<apex:attribute name="rows" type="int" description="how many rows to display in grid" default="19"/>
@@ -69,6 +70,17 @@ Copyright 2011 Jeff Trull <jetrull@sbcglobal.net>
// use JS Remoting to get field metadata info
// TODO check for creatability/updatability of the chosen SObject type by this user
+ // decide whether to use "fieldset" or "fields". Give "fields" priority (for manual override?)
+ var fields = '{!fields}'; // comma separated
+ if ((fields == null) || (fields == '')) {
+ // try fieldset
+ var fieldset = '{!fieldset}';
+ if ((fieldset == null) || (fieldset == '') || (fieldset == '[]')) {
+ Ext.Msg.alert('neither fields nor fieldsets were supplied to this component');
+ return;
+ }
+ fields = fieldset.substr(1, fieldset.length - 2); // remove square brackets
+ }
ExtJSStoreRemotingCtrl.describeFields('{!object}', String('{!fields}'),
function(fieldData, e) {
if (!e.status) {
Please sign in to comment.
Something went wrong with that request. Please try again.