Skip to content

Instantly share code, notes, and snippets.

Created October 17, 2016 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/95d4c076b36d2ee7d5e55452501a07ec to your computer and use it in GitHub Desktop.
Save anonymous/95d4c076b36d2ee7d5e55452501a07ec to your computer and use it in GitHub Desktop.
A short demo of how to apply filters to multiple models in skuid.
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true">
<models>
<model id="Opp1" limit="20" query="true" createrowifnonefound="false" adapter="salesforce" type="" sobject="Opportunity">
<fields>
<field id="Name"/>
<field id="OwnerId"/>
<field id="Owner.Name"/>
<field id="StageName"/>
<field id="CloseDate"/>
</fields>
<conditions>
<condition type="multiple" field="StageName" operator="in" inactive="true" enclosevalueinquotes="true" name="__autofilter__StageName" state="filterableoff" value=""/>
<condition type="fieldvalue" field="CloseDate" operator="gte" inactive="true" enclosevalueinquotes="false" name="__autofilter__start__CloseDate" state="filterableoff" value=""/>
<condition type="fieldvalue" field="CloseDate" operator="lte" inactive="true" enclosevalueinquotes="false" name="__autofilter__end__CloseDate" state="filterableoff" value=""/>
</conditions>
<actions>
<action>
<actions>
<action type="custom" snippet="filterAllModels"/>
</actions>
<events>
<event>models.loaded</event>
</events>
</action>
</actions>
</model>
<model id="Opp2" limit="20" query="true" createrowifnonefound="false" adapter="salesforce" type="" sobject="Opportunity">
<fields>
<field id="Name"/>
<field id="OwnerId"/>
<field id="Owner.Name"/>
<field id="StageName"/>
<field id="CloseDate"/>
</fields>
<conditions>
<condition type="multiple" field="StageName" operator="in" inactive="true" enclosevalueinquotes="true" name="__autofilter__StageName" state="filterableoff" value=""/>
<condition type="fieldvalue" field="CloseDate" operator="gte" inactive="true" enclosevalueinquotes="false" name="__autofilter__start__CloseDate" state="filterableoff" value=""/>
<condition type="fieldvalue" field="CloseDate" operator="lte" inactive="true" enclosevalueinquotes="false" name="__autofilter__end__CloseDate" state="filterableoff" value=""/>
</conditions>
<actions/>
</model>
<model id="Opp3" limit="20" query="true" createrowifnonefound="false" adapter="salesforce" type="" sobject="Opportunity">
<fields>
<field id="Name"/>
<field id="OwnerId"/>
<field id="Owner.Name"/>
<field id="StageName"/>
<field id="CloseDate"/>
</fields>
<conditions>
<condition type="multiple" field="StageName" operator="in" inactive="true" enclosevalueinquotes="true" name="__autofilter__StageName" state="filterableoff" value=""/>
<condition type="fieldvalue" field="CloseDate" operator="gte" inactive="true" enclosevalueinquotes="false" name="__autofilter__start__CloseDate" state="filterableoff" value=""/>
<condition type="fieldvalue" field="CloseDate" operator="lte" inactive="true" enclosevalueinquotes="false" name="__autofilter__end__CloseDate" state="filterableoff" value=""/>
</conditions>
<actions/>
</model>
</models>
<components>
<skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="false" model="Opp1" buttonposition="" mode="readonly" uniqueid="sk-3Jm-tn-103">
<fields/>
<rowactions/>
<massactions usefirstitemasdefault="true"/>
<views>
<view type="standard"/>
</views>
<searchfields/>
<filters>
<filter type="multiselect" filteroffoptionlabel="All Stages" createfilteroffoption="true" affectcookies="true" autocompthreshold="25" conditionsource="auto" labelmode="auto" conditionfield="StageName" conditionoperator="in"/>
<filter type="daterange" filteroffoptionlabel="New Filter" createfilteroffoption="true" affectcookies="true" autocompthreshold="25" conditionsource="auto" labelmode="auto" conditionfield="CloseDate"/>
</filters>
<renderconditions logictype="and"/>
</skootable>
<grid uniqueid="sk-3JmScr-60">
<divisions>
<division behavior="flex" minwidth="100px" ratio="1" verticalalign="top" cssclass="column-table">
<components>
<pagetitle uniqueid="sk-3JmUjT-69" model="Opp1">
<maintitle>Opp Model 1</maintitle>
<actions/>
</pagetitle>
<skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="false" model="Opp1" buttonposition="" mode="readonly" uniqueid="sk-3JnOYV-100">
<fields>
<field id="Name"/>
<field id="StageName"/>
<field id="OwnerId"/>
<field id="CloseDate"/>
</fields>
<rowactions/>
<massactions usefirstitemasdefault="true"/>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
</division>
<division behavior="flex" verticalalign="top" minwidth="100px" ratio="1" cssclass="column-table">
<components>
<pagetitle uniqueid="sk-3JmV9f-72" model="Opp2">
<maintitle>Opp Model 2</maintitle>
<actions/>
</pagetitle>
<skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="false" model="Opp2" buttonposition="" mode="readonly" uniqueid="sk-3JnT6n-123">
<fields>
<field id="Name"/>
<field id="StageName"/>
<field id="OwnerId"/>
<field id="CloseDate"/>
</fields>
<rowactions/>
<massactions usefirstitemasdefault="true"/>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
</division>
<division behavior="flex" verticalalign="top" minwidth="100px" ratio="1" cssclass="column-table">
<components>
<pagetitle uniqueid="sk-3JmVg--75" model="Opp3">
<maintitle>Opp Model 3</maintitle>
<actions/>
</pagetitle>
<skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="false" model="Opp3" buttonposition="" mode="readonly" uniqueid="sk-3Jnf2v-170">
<fields>
<field id="Name"/>
<field id="StageName"/>
<field id="OwnerId"/>
<field id="CloseDate"/>
</fields>
<rowactions/>
<massactions usefirstitemasdefault="true"/>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
</division>
</divisions>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</grid>
</components>
<resources>
<labels/>
<javascript>
<jsitem location="inlinesnippet" name="filterAllModels" cachelocation="false">var params = arguments[0],
$ = skuid.$;
var triggerModel = params.model;
var triggerConditions = triggerModel.conditions;
var allModels = skuid.model.getModelsList();
//iterate though all the page models
$.each(allModels, function(i, model) {
if (triggerModel.objectName == model.objectName) { //make sure we're only concerning ourselves with like-typed models
$.each(triggerConditions, function(j, condition) { //iterate through all the triggering model's conditions
var conditionToUpdate = model.getConditionByName(condition.name);
if (conditionToUpdate &amp;&amp; (conditionToUpdate.inactive != condition.inactive || conditionToUpdate.values != condition.values)) {
if (conditionToUpdate.type == 'multiple') { //use values
model.setCondition(conditionToUpdate, JSON.parse(JSON.stringify(condition.values))); //deep clone via JSON stringify
} else {
model.setCondition(conditionToUpdate, JSON.parse(JSON.stringify(condition.value))); //deep clone via JSON stringify
}
conditionToUpdate.inactive = condition.inactive; //sync the active/inactive
model.updateData()
}
});
}
});
</jsitem>
</javascript>
<css>
<cssitem location="inline" name="column-table" cachelocation="false">.column-table {
border-left : 3px solid #000;
border-right : 3px solid #000;
padding: 0 2px;
}</cssitem>
</css>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment