remember last-selected filter value when source is rows in a model

  • 1
  • Problem
  • Updated 4 weeks ago
  • In Progress
I am using a filter that sources it's picklist options from another model.  I want the filter to remember the last selected filter value and have selected the tick box to enable that but the filter does not remember and resets to "all" on page load. Other filters on the table are able to remember just not the one using another model.
Photo of Tyler Fisher

Tyler Fisher

  • 388 Points 250 badge 2x thumb

Posted 4 weeks ago

  • 1
Photo of Matt Davis

Matt Davis, Employee

  • 734 Points 500 badge 2x thumb
Do you have an example of where it's not working for you? It seems like it's working for me in this example - 
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
    <models>
        <model id="AccountsOnMyOpps" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Opportunity" type="aggregate">
            <fields>
                <field id="Id" name="countId" function="COUNT"/>
            </fields>
            <conditions>
                <condition type="userinfo" value="" field="OwnerId" fieldtargetobjects="User" operator="=" enclosevalueinquotes="true" userinfotype="userid"/>
            </conditions>
            <actions/>
            <groupby method="simple">
                <field id="AccountId" name="accountId"/>
                <field id="Account.Name" name="accountName"/>
            </groupby>
        </model>
        <model id="Opps" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Opportunity">
            <fields>
                <field id="Id"/>
                <field id="Name"/>
                <field id="StageName"/>
                <field id="Type"/>
                <field id="ForecastCategoryName"/>
                <field id="Amount"/>
                <field id="AccountId"/>
                <field id="Account.Name"/>
            </fields>
            <conditions>
                <condition type="fieldvalue" value="" enclosevalueinquotes="true" field="AccountId" fieldtargetobjects="Account" state="filterableoff" inactive="true" name="AccountId"/>
            </conditions>
            <actions/>
        </model>
    </models>
    <components>
        <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="false" model="AccountsOnMyOpps" buttonposition="" mode="readonly" allowcolumnreordering="true" responsive="true" uniqueid="sk-iu4-458" heading="AccountsOnMyOpps">
            <fields>
                <field id="Id" name="countId" uniqueid="fi-iu4-459"/>
                <field id="AccountId" name="accountId" uniqueid="fi-iu4-460"/>
                <field id="Account.Name" name="accountName" uniqueid="fi-iu4-461"/>
            </fields>
            <rowactions/>
            <massactions usefirstitemasdefault="true"/>
            <views>
                <view type="standard"/>
            </views>
        </skootable>
        <filterset model="Opps" searchmethod="server" searchbox="true" uniqueid="sk-iua-776">
            <filters>
                <filter type="select" createfilteroffoption="true" affectcookies="true" autocompthreshold="25" conditionsource="manual" filtermethod="server" labelmode="no" condition="AccountId" filteroffoptionlabel="All Accounts">
                    <sources>
                        <source type="model" effectsbehavior="justdefault" model="AccountsOnMyOpps">
                            <labeltemplate>{{{accountName}}}</labeltemplate>
                            <valuetemplate>{{{accountId}}}</valuetemplate>
                        </source>
                    </sources>
                </filter>
            </filters>
            <searchfields/>
        </filterset>
        <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="Opps" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-iuT-667" heading="Opps">
            <fields>
                <field id="Id" uniqueid="fi-iuT-668"/>
                <field id="Name" uniqueid="fi-iuT-669"/>
                <field id="AccountId" hideable="true" uniqueid="fi-ius-821"/>
                <field id="StageName" uniqueid="fi-iuT-670"/>
                <field id="Type" uniqueid="fi-iuT-671"/>
                <field id="ForecastCategoryName" uniqueid="fi-iuT-672"/>
                <field id="Amount" uniqueid="fi-iuT-673"/>
            </fields>
            <rowactions>
                <action type="edit"/>
                <action type="delete"/>
            </rowactions>
            <massactions usefirstitemasdefault="true">
                <action type="massupdate"/>
                <action type="massdelete"/>
            </massactions>
            <views>
                <view type="standard"/>
            </views>
        </skootable>
    </components>
    <resources>
        <labels/>
        <javascript>
            <jsitem location="inlinesnippet" name="onSelectUser" cachelocation="false">var eventId = arguments[0].event.Id;
var eventModel = skuid.model.getModel("SelectedUser");
var idCondition = eventModel.getConditionByName("SelectedUserId");
eventModel.emptyData();
eventModel.setCondition(idCondition, eventId);
eventModel.updateData();</jsitem>
            <jsitem location="inlinesnippet" name="newSnippet" cachelocation="false">var params = arguments[0],
$ = skuid.$;
console.log(params);</jsitem>
        </javascript>
        <css/>
        <actionsequences uniqueid="sk-3N03-382">
            <actionsequence id="c5ebd6f8-9dd1-4edf-93a2-6024935b6529" label="The Sequence" type="reusable" uniqueid="sk-FG8-316">
                <description/>
                <actions>
                    <action type="createRow" model="UI_Only" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="context"/>
                    <action type="updateRow" fieldmodel="SelectedUser" affectedrows="context" field="hi" enclosevalueinquotes="true" value="{{$Model.SelectedUser.data.0.hi}}1"/>
                    <action type="custom" snippet="newSnippet"/>
                </actions>
            </actionsequence>
            <actionsequence id="e85374dd-85a1-4320-9010-540ab0169269" label="The Sequence Popup" type="reusable" uniqueid="sk-FG8-316">
                <description/>
                <actions>
                    <action type="showPopup">
                        <popup title="New Popup" width="90%">
                            <components/>
                        </popup>
                    </action>
                </actions>
            </actionsequence>
        </actionsequences>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>

Photo of Tyler Fisher

Tyler Fisher

  • 388 Points 250 badge 2x thumb
Hi Matt,
Thanks for your help.  In your example if you change the filter type to multi-select option then the filter fails to remember the last selected value, which is the problem I am having.  I want to have a multi-select filter; when I changed it to select option the filter was able to remember, so we've isolated the problem (progress).
-
<skuidpage showheader="true" personalizationmode="server" showsidebar="true" unsavedchangeswarning="yes" useviewportmeta="true">
    <models>
        <model id="AccountsOnMyOpps" type="aggregate" datasource="salesforce" createrowifnonefound="false" query="true" sobject="Opportunity" limit="20">
            <fields>
                <field id="Id" name="countId" function="COUNT" />
            </fields>
            <conditions>
                <condition type="userinfo" value="" enclosevalueinquotes="true" field="OwnerId" operator="=" fieldtargetobjects="User" userinfotype="userid" />
            </conditions>
            <actions />
            <groupby method="simple">
                <field id="AccountId" name="accountId" />mu
                <field id="Account.Name" name="accountName" />
            </groupby>
        </model>
        <model id="Opps" datasource="salesforce" createrowifnonefound="false" query="true" sobject="Opportunity" limit="20">
            <fields>
                <field id="Id" />
                <field id="Name" />
                <field id="StageName" />
                <field id="Type" />
                <field id="ForecastCategoryName" />
                <field id="Amount" />
                <field id="AccountId" />
                <field id="Account.Name" />
            </fields>
            <conditions>
                <condition type="fieldvalue" name="AccountId" value="" enclosevalueinquotes="true" field="AccountId" fieldtargetobjects="Account" inactive="true" state="filterableoff" />
            </conditions>
            <actions />
        </model>
    </models>
    <components>
        <skootable uniqueid="sk-iu4-458" model="AccountsOnMyOpps" mode="readonly" buttonposition="" createrecords="false" pagesize="10" showexportbuttons="false" searchbox="true" searchmethod="server" showerrorsinline="true" showsavecancel="false" showconditions="true" heading="AccountsOnMyOpps" responsive="true" allowcolumnreordering="true" alwaysresetpagination="false" hidefooter="false" hideheader="false">
            <fields>
                <field id="Id" name="countId" uniqueid="fi-iu4-459" />
                <field id="AccountId" name="accountId" uniqueid="fi-iu4-460" />
                <field id="Account.Name" name="accountName" uniqueid="fi-iu4-461" />
            </fields>
            <rowactions />
            <massactions usefirstitemasdefault="true" />
            <views>
                <view type="standard" />
            </views>
        </skootable>
        <filterset uniqueid="sk-iua-776" model="Opps" searchbox="true" searchmethod="server">
            <filters>
                <filter type="multiselect" condition="AccountId" createfilteroffoption="true" filteroffoptionlabel="All Accounts" filtermethod="server" labelmode="no" conditionsource="manual" autocompthreshold="25" affectcookies="true">
                    <sources>
                        <source type="model" model="AccountsOnMyOpps" effectsbehavior="justdefault">
                            <labeltemplate>{{{accountName}}}</labeltemplate>
                            <valuetemplate>{{{accountId}}}</valuetemplate>
                        </source>
                    </sources>
                </filter>
            </filters>
            <searchfields />
        </filterset>
        <skootable uniqueid="sk-iuT-667" model="Opps" mode="read" buttonposition="" createrecords="true" pagesize="10" showexportbuttons="false" searchbox="true" searchmethod="server" showerrorsinline="true" showsavecancel="true" showconditions="true" heading="Opps" responsive="true" allowcolumnreordering="true" alwaysresetpagination="false" hidefooter="false" hideheader="false">
            <fields>
                <field id="Id" uniqueid="fi-iuT-668" />
                <field id="Name" uniqueid="fi-iuT-669" />
                <field id="AccountId" uniqueid="fi-ius-821" hideable="true" />
                <field id="StageName" uniqueid="fi-iuT-670" />
                <field id="Type" uniqueid="fi-iuT-671" />
                <field id="ForecastCategoryName" uniqueid="fi-iuT-672" />
                <field id="Amount" uniqueid="fi-iuT-673" />
            </fields>
            <rowactions>
                <action type="edit" />
                <action type="delete" />
            </rowactions>
            <massactions usefirstitemasdefault="true">
                <action type="massupdate" />
                <action type="massdelete" />
            </massactions>
            <views>
                <view type="standard" />
            </views>
        </skootable>
    </components>
    <resources>
        <labels />
        <javascript>
            <jsitem name="onSelectUser" cachelocation="false" location="inlinesnippet">var eventId = arguments[0].event.Id;
var eventModel = skuid.model.getModel("SelectedUser");
var idCondition = eventModel.getConditionByName("SelectedUserId");
eventModel.emptyData();
eventModel.setCondition(idCondition, eventId);
eventModel.updateData();</jsitem>
            <jsitem name="newSnippet" cachelocation="false" location="inlinesnippet">var params = arguments[0],
$ = skuid.$;
console.log(params);</jsitem>
        </javascript>
        <css />
        <actionsequences uniqueid="sk-3N03-382">
            <actionsequence id="c5ebd6f8-9dd1-4edf-93a2-6024935b6529" type="reusable" label="The Sequence" uniqueid="sk-FG8-316">
                <description />
                <actions>
                    <action type="createRow" model="UI_Only" defaultmodefornewitems="edit" appendorprepend="prepend" affectedrows="context" />
                    <action type="updateRow" value="{{$Model.SelectedUser.data.0.hi}}1" enclosevalueinquotes="true" field="hi" fieldmodel="SelectedUser" affectedrows="context" />
                    <action type="custom" snippet="newSnippet" />
                </actions>
            </actionsequence>
            <actionsequence id="e85374dd-85a1-4320-9010-540ab0169269" type="reusable" label="The Sequence Popup" uniqueid="sk-FG8-316">
                <description />
                <actions>
                    <action type="showPopup">
                        <popup title="New Popup" width="90%">
                            <components />
                        </popup>
                    </action>
                </actions>
            </actionsequence>
        </actionsequences>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none" />
    </styles>
</skuidpage>