Skip to main content

Checkbox list under Shared Element is to be shown multiple times in different panel parameters.

Comments

17 comments

  • VISUI

    I think your jQuery selectors are too generic.  

    ".liststyle" will select all instances of that class within the DOM.

    "#showMe" will likewise select all instances of that class within the DOM.

    Logi dashboards append a panel instance ID to items such as inputs within the dashboard panel and panel parameters when rendered.  You can leverage this unique id with the token @Function.InstanceID~

    You could pass the InstanceID as a shared element parameter into your shared element and utilize it to uniquely identify objects within shared element.  You can then modify your javascript with the same unique identifier so that your jQuery selectors are specific.

    VISUI can help build out a solution for you.




    0
  • Anvita Rastogi

    Hi VISUI,

    Now I have changed the script by replacing it with the Instance Id 

    update the checkbox list class with the rdICL-period_@Function.InstanceID~and pass the instance id as in the shared element


    So far as I can tell, logi works differently with checkbox lists than it does with input hidden fields. Only the value is updated, but the id and class remain the same.


    But the issue remains the same and after implementing this show hide functionality is not working





    0
  • Glyn McKenna

    Have updated this comment as it does not address the main issue being described, which is adding a shared checkbox list to panel parameters on multiple dashboard panels.

    I'll leave it for the checkbox list example using an action refresh in case it is helpful to others

    You don't always need to use JavaScript, you can use a normal Action.Refresh to refresh the "showMe" DIV and the set a condition on the DIV inside the "showMe" DIV. This uses an Ajax refresh, so it happens server-side and replaces the DOM beneath the refresh element. This is quite quick for this specific use case however a client-side implementation using the action JavaScript may serve your needs better and reduce client server interactions

    Here is an example report definition XML:

    <Report ID="CheckboxListToggle" SavedBy="LOGIXML\gmcKenna" SavedAt="2021-10-21 18:50:43" EngineVersion="12.8.675-SP1">
    <StyleSheet ID="ssBootstrap-431" StyleSheet="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" Theme="Silver" />
    <Body>
    <Division ID="divContainer" HtmlDiv="True" Class="container pt-5">
    <Division ID="divPeriod" HtmlDiv="True" Class="card">
    <Label Class="card-header" ID="lblCardTitle" Caption="Checkbox List Toggle Example" HtmlTag="h3" />
    <InputGrid CaptionWidth="50" Layout="Auto" WidthScale="%" ID="igInputs" GridWidth="100" Class="pt-5">
    <InputCheckboxList OptionCaptionColumn="period" OptionValueColumn="period" ID="pPeriod" DefaultValue="@Request.cblPeriod~" MultiSelect="False">
    <DataLayer Type="Static" ID="StaticOne">
    <StaticDataRow id="1" period="Weekly" />
    <StaticDataRow id="2" period="Monthly" />
    <StaticDataRow id="3" period="Yearly" />
    <StaticDataRow id="4" period="Period To Date" />
    <StaticDataRow id="5" period="Custom Dates" />
    <DataLayerLink ID="dllStaticOne" />
    </DataLayer>
    <EventHandler DhtmlEvent="onchange">
    <Action Type="RefreshElement" ElementID="divCustom" ID="actRefCustom" />
    </EventHandler>
    </InputCheckboxList>
    </InputGrid>
    <Division ID="divCustom" HtmlDiv="True">
    <Division ID="divShowMe" HtmlDiv="True" Condition="&quot;@Request.pPeriod~&quot; == &quot;Custom Dates&quot;">
    <HR />
    <Division ID="divRow" Class="row px-5" HtmlDiv="True">
    <Division ID="divColStart" HtmlDiv="True" Class="col">
    <HtmlTag HtmlTagName="label" HtmlTagText="Start Date:" ID="lblStartDate">
    <HtmlAttributeParams for="startDate" />
    </HtmlTag>
    <InputDate ID="startDate" DefaultValue="@Request.startDate~" Class="form-control" CalendarLinkType="None" />
    </Division>
    <Division ID="divColEnd" HtmlDiv="True" Class="col">
    <HtmlTag HtmlTagName="label" HtmlTagText="End Date:" ID="lblEndDate">
    <HtmlAttributeParams for="endDate" />
    </HtmlTag>
    <InputDate ID="endDate" DefaultValue="@Request.endDate~" Class="form-control" CalendarLinkType="None" />
    </Division>
    </Division>
    </Division>
    <LineBreak />
    <Button ID="btnDone" Caption="Done" Class="btn btn-default float-right" />
    </Division>
    </Division>
    </Division>
    </Body>
    <ideTestParams cblPeriod="" startDate="" endDate="" pPeriod="" />
    </Report>
    0
  • Glyn McKenna

    If you really need to use JavaScript to change the display mode, you will have to iterate over your checkbox list in the script (Action Refresh does this for you)

    See example report definition:

    <Report ID="CheckboxListToggle" SavedBy="LOGIXML\gmcKenna" SavedAt="2021-10-21 19:26:50" EngineVersion="12.8.675-SP1">
    <StyleSheet ID="ssBootstrap-431" StyleSheet="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" Theme="Silver" />
    <Body>
    <Division ID="divContainer" HtmlDiv="True" Class="container pt-5">
    <Division ID="divPeriod" HtmlDiv="True" Class="card">
    <Label Class="card-header" ID="lblCardTitle" Caption="Checkbox List Toggle Example" HtmlTag="h3" />
    <InputGrid CaptionWidth="50" Layout="Auto" WidthScale="%" ID="igInputs" GridWidth="100" Class="pt-5">
    <InputCheckboxList OptionCaptionColumn="period" OptionValueColumn="period" ID="pPeriod" DefaultValue="@Request.cblPeriod~" MultiSelect="False">
    <DataLayer Type="Static" ID="StaticOne">
    <StaticDataRow id="1" period="Weekly" />
    <StaticDataRow id="2" period="Monthly" />
    <StaticDataRow id="3" period="Yearly" />
    <StaticDataRow id="4" period="Period To Date" />
    <StaticDataRow id="5" period="Custom Dates" />
    <DataLayerLink ID="dllStaticOne" />
    </DataLayer>
    <EventHandler DhtmlEvent="onchange">
    <Action Type="Javascript" ID="actToggleShowMe" Javascript="var arry = Array.from(document.querySelectorAll(&quot;#pPeriod ul li&quot;)); &#xD;&#xA;var selval = arry.filter( e =&gt; e.firstChild.firstChild.checked === true );&#xD;&#xA;var showMe = document.getElementById(&quot;divShowMe&quot;);&#xD;&#xA;if(selval.length &gt; 0){&#xD;&#xA; selval = selval[0].innerText;&#xD;&#xA; selval === &quot;Custom Dates&quot;? showMe.style.display=&quot;block&quot; : showMe.style.display=&quot;none&quot;;&#xD;&#xA;} else { showMe.style.display=&quot;none&quot; }" />
    </EventHandler>
    </InputCheckboxList>
    </InputGrid>
    <Division ID="divCustom" HtmlDiv="True">
    <Division ID="divShowMe" HtmlDiv="True" Tooltip="&quot;@Request.pPeriod~&quot; == &quot;Custom Dates&quot;" ShowModes="None">
    <HR />
    <Division ID="divRow" Class="row px-5" HtmlDiv="True">
    <Division ID="divColStart" HtmlDiv="True" Class="col">
    <HtmlTag HtmlTagName="label" HtmlTagText="Start Date:" ID="lblStartDate">
    <HtmlAttributeParams for="startDate" />
    </HtmlTag>
    <InputDate ID="startDate" DefaultValue="@Request.startDate~" Class="form-control" CalendarLinkType="None" />
    </Division>
    <Division ID="divColEnd" HtmlDiv="True" Class="col">
    <HtmlTag HtmlTagName="label" HtmlTagText="End Date:" ID="lblEndDate">
    <HtmlAttributeParams for="endDate" />
    </HtmlTag>
    <InputDate ID="endDate" DefaultValue="@Request.endDate~" Class="form-control" CalendarLinkType="None" />
    </Division>
    </Division>
    </Division>
    <LineBreak />
    <Button ID="btnDone" Caption="Done" Class="btn btn-default float-right" />
    </Division>
    </Division>
    </Division>
    </Body>
    <ideTestParams cblPeriod="" startDate="" endDate="" pPeriod="" />
    </Report>
    0
  • VISUI

    Sorry.  I think you misunderstood a bit about the InstanceID.  Hopefully this example will clear it up for you.

    In order for this example to work, you will need to change the reference of the Shared Element to the name of the report you place this code in.


    <Report ID="LogiForum.dashboard">
    <IncludeScriptFile IncludedScriptFile="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js" />
    <Body>
    <Dashboard2 AllowFreeformLayout="False" DashboardAdjustable="True" DashboardColumns="3" ID="dash01" SaveFile="@Function.AppDownloadPath~\test01.xml">
    <Panel Caption="Panel1" ID="pnl1" MultipleInstances="True">
    <PanelContent>
    <Label Caption="@Request.inpColor~" />
    </PanelContent>
    <PanelParameters>
    <IncludeSharedElement DefinitionFile="LogiForum.dashboard" SharedElementID="input">
    <SharedElementParams InstanceID="@Function.InstanceID~" />
    </IncludeSharedElement>
    </PanelParameters>
    </Panel>
    </Dashboard2>
    </Body>
    <SharedElement ID="input">
    <InputCheckboxList DefaultValue="@Request.inpColor~" ID="inpColor" IncludeBlank="True" OptionCaptionColumn="Color" OptionValueColumn="Color" MultiSelect="False">
    <DataLayer Type="Static">
    <StaticDataRow Color="Red" />
    <StaticDataRow Color="Blue" />
    <StaticDataRow Color="Green" />
    <StaticDataRow Color="Custom" />
    </DataLayer>
    <EventHandler DhtmlEvent="onchange">
    <Action Type="Javascript" ID="js" Javascript="var v = $('#rdICL-inpColor_@Shared.InstanceID~').val();&#xD;&#xA;console.log(v);&#xD;&#xA;&#xD;&#xA;if (v == 'Custom') {&#xD;&#xA; $('#showMe_@Shared.InstanceID~').show();&#xD;&#xA; }&#xD;&#xA;else {&#xD;&#xA; $('#showMe_@Shared.InstanceID~').hide();&#xD;&#xA; }&#xD;&#xA;" />
    </EventHandler>
    </InputCheckboxList>
    <Division ID="showMe_@Shared.InstanceID~" Class="ThemeHidden">
    <Label Caption="Show Custom Code" />
    </Division>
    </SharedElement>
    <ideTestParams inpColor="" />
    </Report>

     

    Glynn,

    I believe that Anvita will have the same issues with your solution using the Action.Refresh since the division's ID will not be unique.  She would still have to append the InstanceID to it and refresh that that element.


    I also think the javascript used to show/hide will perform much better since there is no need to go back to the server to refresh any content.  All that needs to be done is to either remove / add the class or perform a jQuery show() / hide().


    0
  • Anvita Rastogi

    Hi Glyn,
    The issue is that if I apply this checkbox list in the dashboard panel by using the shared element for one panel, it works fine, but when I implement or add this shared element in multiple panels, it does not work. The report loads with a blank, and the javascript that I have applied for the show and hide functionality does not work either.


    Thanks and Regards 
    Anvita

    0
  • Glyn McKenna

    Sorry guys, I missed that completely. Thanks for pointing it out! I'll have another look in the morning

    1
  • Anvita Rastogi

    Yes so is there any way to use it multiple times in the dashboard panels

    0
  • Glyn McKenna

    Hi Anvita,

    Try this

    <Report ID="LogiForum.dashboard" SavedBy="LOGIXML\gmcKenna" SavedAt="2021-10-21 21:01:07" EngineVersion="12.8.675-SP1">
    <Body>
    <Dashboard2 AllowFreeformLayout="False" DashboardAdjustable="True" DashboardColumns="3" ID="dash01" SaveFile="@Function.AppDownloadPath~\test01.xml">
    <Panel Caption="Panel1" ID="pnl1" MultipleInstances="True">
    <PanelContent>
    <Label Caption="Start Date: @Request.startDate~" />
    <LineBreak />
    <Label Caption="End Date: @Request.endDate~" />
    </PanelContent>
    <PanelParameters>
    <IncludeSharedElement DefinitionFile="LogiForum.dashboard" SharedElementID="input">
    <SharedElementParams InstanceID="@Function.InstanceID~" />
    </IncludeSharedElement>
    </PanelParameters>
    </Panel>
    <Panel Caption="Panel2" ID="pnl2" MultipleInstances="True">
    <PanelContent>
    <Label Caption="Start Date: @Request.startDate~" />
    <LineBreak />
    <Label Caption="End Date: @Request.endDate~" />
    </PanelContent>
    <PanelParameters>
    <IncludeSharedElement DefinitionFile="LogiForum.dashboard" SharedElementID="input">
    <SharedElementParams InstanceID="@Function.InstanceID~" />
    </IncludeSharedElement>
    </PanelParameters>
    </Panel>
    </Dashboard2>
    </Body>
    <SharedElement ID="input">
    <InputCheckboxList OptionCaptionColumn="period" OptionValueColumn="period" ID="pPeriod_@Shared.InstanceID~" DefaultValue="@Request.cblPeriod~" MultiSelect="False">
    <DataLayer Type="Static" ID="StaticOne">
    <StaticDataRow id="1" period="Weekly" />
    <StaticDataRow id="2" period="Monthly" />
    <StaticDataRow id="3" period="Yearly" />
    <StaticDataRow id="4" period="Period To Date" />
    <StaticDataRow id="5" period="Custom Dates" />
    <DataLayerLink ID="dllStaticOne" />
    </DataLayer>
    <EventHandler DhtmlEvent="onchange">
    <Action Type="Javascript" ID="actToggleShowMe" Javascript="var arry = Array.from(document.querySelectorAll(&quot;#pPeriod_@Shared.InstanceID~ ul li&quot;)); &#xD;&#xA;var selval = arry.filter( e =&gt; e.firstChild.firstChild.checked === true );&#xD;&#xA;var showMe = document.getElementById(&quot;showMe_@Shared.InstanceID~&quot;);&#xD;&#xA;if(selval.length &gt; 0){&#xD;&#xA; selval = selval[0].innerText;&#xD;&#xA; selval === &quot;Custom Dates&quot;? showMe.style.display=&quot;block&quot; : showMe.style.display=&quot;none&quot;;&#xD;&#xA;} else { showMe.style.display=&quot;none&quot; }" />
    </EventHandler>
    </InputCheckboxList>
    <Division ID="divCustom" HtmlDiv="True">
    <Division ID="showMe_@Shared.InstanceID~" HtmlDiv="True" ShowModes="None">
    <HR />
    <Division ID="divRow" Class="row px-5" HtmlDiv="True">
    <Division ID="divColStart" HtmlDiv="True" Class="col">
    <HtmlTag HtmlTagName="label" HtmlTagText="Start Date:" ID="lblStartDate">
    <HtmlAttributeParams for="startDate" />
    </HtmlTag>
    <InputDate ID="startDate" DefaultValue="@Request.startDate~" Class="form-control" CalendarLinkType="None" />
    </Division>
    <Division ID="divColEnd" HtmlDiv="True" Class="col">
    <HtmlTag HtmlTagName="label" HtmlTagText="End Date:" ID="lblEndDate">
    <HtmlAttributeParams for="endDate" />
    </HtmlTag>
    <InputDate ID="endDate" DefaultValue="@Request.endDate~" Class="form-control" CalendarLinkType="None" />
    </Division>
    </Division>
    </Division>
    </Division>
    </SharedElement>
    <ideTestParams cblPeriod="" startDate="" endDate="" />
    </Report>
    1
  • Anvita Rastogi

    Will look at it in the morning and let you know about it

    0
  • VISUI

    Anvila,

    See my example listed above.  Demonstrates the shared element approach within a dashboard that works in multiple dashboard panels within panel paramters.

    0
  • Anvita Rastogi

    Sure VISUI both the solutions I will implement in the morning and let you know about the result

    0
  • Anvita Rastogi

    Hi VISUI

    I attempted to do so using your approach, however, it does not work for multiple panels. When I run the report you shared, the checkbox list displays in the edit configuration, but the show hide functionality is disabled, and the panel content is blank.

    0
  • Anvita Rastogi

    Hi Glyn McKenna

    I tried your approach as well, but I'm having the same problem (i.e., it does not work for multiple panels. When run the report you shared, the checkbox list displays in the edit configuration, but the show hide functionality is disabled, and the panel content is blank.)

     

    0
  • Glyn McKenna

    Hi Anvita,

    Okay, both John's and my own sample are working for me on my system with multiple panels. I'll contact you directly and see if we can get online to take a look to see if we can spot any differences in the configurations that might be causing you issues

    Regards
    Glyn

    0
  • Anvita Rastogi

    Thanks Glyn McKenna .The solution you provided is extremely beneficial to us. Once again Thank you for your assistance.

    0
  • Juan Alonso

    Good stuff!

    0

Please sign in to leave a comment.