Skip to main content

count the how many checkboxes are selected/checked and store into one element and show in different report definition

Comments

1 comment

  • Glyn McKenna

    Hi Govind,

    Sorry for the delay in responding, hopefully you found a solution, but just in case you didn't or for future reference, I've added a simple example report definition below, that uses an "Action JavaScript" to combine some custom JavaScript that first counts the checked checkboxes in the the list and then passes the count value to an "Action Refresh" JavaScript function as a new parameter on the query string to refresh the labels in the div below it. I hope this helps

    <Report ID="CheckboxListCount" SavedBy="LOGIXML\gmcKenna" SavedAt="2021-10-19 13:53:42" 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-fluid">
    <Division ID="divSelectLists" HtmlDiv="True" Class="card p-4 m-4">
    <InputGrid CaptionWidth="50" Layout="Auto" WidthScale="%" ID="igItems" GridWidth="100">
    <InputCheckboxList OptionCaptionColumn="item" OptionValueColumn="item" ID="cblItems" DefaultValue="@Request.cblItems~" MultiSelect="True">
    <DataLayer Type="Static" ID="StaticOne">
    <StaticDataRow id="1" item="Hammer" json_val="{&quot;make&quot;:&quot;Stanley&quot;, &quot;model&quot;:&quot;HAMPIN001&quot;, &quot;version&quot;:0.1}" />
    <StaticDataRow id="2" item="Screwdriver Set" json_val="{&quot;make&quot;:&quot;Silverline&quot;, &quot;model&quot;:&quot;SCREWELEC002&quot;, &quot;version&quot;:&quot;2.3&quot;}" />
    <StaticDataRow id="3" item="Tenon saw" json_val="{&quot;make&quot;:&quot;Total&quot;, &quot;model&quot;:&quot;SAWTEN001&quot;, &quot;version&quot;:&quot;0.3&quot;}" />
    <StaticDataRow id="4" item="No 4 Plane" json_val="{&quot;make&quot;:&quot;Stanley&quot;, &quot;model&quot;:&quot;PLANE04001&quot;, &quot;version&quot;:&quot;0.1&quot;}" />
    <StaticDataRow id="5" item="Pin nails 25mm x 50" json_val="{&quot;make&quot;:&quot;Challenge&quot;, &quot;model&quot;:&quot;PIN25X50001&quot;, &quot;version&quot;:&quot;0.1&quot;}" />
    <DataLayerLink ID="dllStaticOne" />
    </DataLayer>
    <EventHandler DhtmlEvent="onchange">
    <Action Type="Javascript" ID="actSetValues" Javascript="var arry = Array.from(document.querySelectorAll(&quot;#cblItems ul li&quot;)); var selcount = arry.filter( e =&gt; e.firstChild.innerText !== 'Check all' &amp;&amp; e.firstChild.firstChild.checked === true ).length;&#xD;&#xA;rdAjaxRequestWithFormVars('rdAjaxCommand=RefreshElement&amp;rdRefreshElementID=divContainer&amp;rdReport=@Request.rdReport~&amp;selcount=' + selcount,'false','',true,null,null,null,true);" />
    </EventHandler>
    </InputCheckboxList>
    </InputGrid>
    </Division>
    <Division ID="divSelected" HtmlDiv="True" Class="card p-4 m-4">
    <Label HtmlTag="h1" Caption="Selected Items: @Request.cblItems~" />
    <Label Caption="Number of items selected: @Request.selcount~" HtmlTag="h2" />
    </Division>
    </Division>
    </Body>
    <ideTestParams cblItems="" selcount="" />
    </Report>
    0

Please sign in to leave a comment.