Updating Input Checkbos List (Prevent concatenation)
I have a checkbox list which i want to update from a selection of a parent select list. But when I do this it just concatenates the values instead of overwriting them? Any ideas or anyone experienced the same issue?
-
<?xml version="1.0" encoding="utf-8"?>
<Report
ID="LOGI.CheckBoxList"
>
<DefaultRequestParams
hdnTeamsList="LIV,UTD,CHE"
selFilter-ActivePractices="ALL"
selFilter-HB="7A4"
selFilter-Teams="LIV,UTD,CHE"
/>
<Body>
<Division
ID="Filters"
>
<ResponsiveRow>
<ResponsiveColumn>
<Division
ID="Filter-Sport"
>
<InputSelectList
Caption="Sport:"
Class="TextNormal"
DefaultValue="@Request.selFilter-Sport~"
ID="selFilter-Sport"
OptionCaptionColumn="Sport"
OptionValueColumn="ID"
>
<DataLayer
Type="Static"
>
<StaticDataRow
ID="1"
Sport="Football"
/>
<StaticDataRow
ID="2"
Sport="Rugby"
/>
<StaticDataRow
ID="3"
Sport="Cricket"
/>
</DataLayer>
<EventHandler
DhtmlEvent="onchange"
>
<Action
ElementID="Filter-Dummy"
ID="actRefresh"
PostRefreshJavascript="const txtTarget = document.getElementById("hdnTeamsList");
var selSelectedSport = document.getElementById('selFilter-Sport').value;
switch (selSelectedSport) {
case '1':
TeamList = "LIV,UTD,CHE";
break;
case '2':
TeamList = "OSP,DRA,WAS";
break;
case '3':
TeamList = "GLA,MID,SUR";
}txtTarget.value = TeamList;"
Type="RefreshElement"
/>
</EventHandler>
</InputSelectList>
<Remark>
<InputText
ID="hdnTeamsList"
/>
</Remark>
<InputText
DefaultValue="@Request.hdnTeamsList~"
ID="hdnTeamsList"
/>
</Division>
</ResponsiveColumn>
<ResponsiveColumn>
<Division
ID="Filter-Dummy"
/>
</ResponsiveColumn>
</ResponsiveRow>
<ResponsiveRow>
<ResponsiveColumn>
<Rows
Width="100"
WidthScale="%"
>
<Row>
<Column
Width="50"
WidthScale="%"
>
<Division
Class="div-bt-filter"
ID="div-bt-filter"
>
<Label
Caption="Filter"
Class="btn btn-success btn-lg"
>
<Action
ElementID="Content-Stage"
ID="actRefresh"
PostRefreshJavascript="const txtSource = document.getElementById("hdnTeamsList").value;
const txtTarget = document.getElementById("selFilter-Teams");//alert(txtSource);
rdAjaxRequestWithFormVars('rdAjaxCommand=RefreshElement&rdRefreshElementID=Filter-Teams&selFilter-Teams=abc&rdReport=LOGI.CheckBoxList','//true','',null,null,null,null,true);
rdAjaxRequestWithFormVars('rdAjaxCommand=RefreshElement&rdRefreshElementID=Panel-Teams&selFilter-Teams=' + txtSource + '&rdReport=LOGI.CheckBoxList','true','',null,null,null,null,true);
"
Type="RefreshElement"
Validate="True"
>
<WaitPage/>
<LinkParams/>
</Action>
</Label>
</Division>
</Column>
</Row>
</Rows>
</ResponsiveColumn>
</ResponsiveRow>
</Division>
<Division
Class="BlueTheme"
ID="Content-Stage"
>
<LineBreak
LineCount="5"
/>
<Division
Class="width-450px"
HtmlDiv="True"
ID="Panel-Teams"
>
<ResponsiveRow>
<ResponsiveColumn>
<Division
HtmlDiv="True"
ID="Filter-Team"
>
<InputCheckboxList
Caption="Teams:"
CaptionClass="TextBlack ThemeBold"
CheckboxListDropdown="True"
Class="TextBlack"
DefaultValue="@Request.selFilter-Teams~"
DropdownButtonClass="form-control"
DropdownNoneSelectedCaption="Select Teams"
DropdownSelectedCaption="# selected"
EnableSearch="False"
ID="selFilter-Teams"
OptionCaptionColumn="Team"
OptionValueColumn="TeamID"
Width="600"
WidthScale="px"
>
<CheckboxListBranch
OptionCaptionColumn="Sport"
/>
<DataLayer
Type="Static"
>
<StaticDataRow
Sport="Football"
SportID="1"
Team="Liverpool"
TeamID="LIV"
/>
<StaticDataRow
Sport="Football"
SportID="1"
Team="Man Utd"
TeamID="UTD"
/>
<StaticDataRow
Sport="Football"
SportID="1"
Team="Chelsea"
TeamID="CHE"
/>
<StaticDataRow
Sport="Rugby"
SportID="2"
Team="Ospreys"
TeamID="OSP"
/>
<StaticDataRow
Sport="Rugby"
SportID="2"
Team="Dragons"
TeamID="DRA"
/>
<StaticDataRow
Sport="Rugby"
SportID="2"
Team="Wasps"
TeamID="WAS"
/>
<StaticDataRow
Sport="Cricket"
SportID="3"
Team="Glamorgan"
TeamID="GLA"
/>
<StaticDataRow
Sport="Cricket"
SportID="3"
Team="Middlesex"
TeamID="MID"
/>
<StaticDataRow
Sport="Cricket"
SportID="3"
Team="Surrey"
TeamID="SUR"
/>
<GroupFilter
GroupColumn="Sport"
Hierarchical="True"
KeepGroupedRows="True"
/>
</DataLayer>
</InputCheckboxList>
</Division>
</ResponsiveColumn>
</ResponsiveRow>
</Division>
</Division>
</Body>
<ideTestParams
hdnTeamsList=""
selFilter-Sport=""
selFilter-Teams=""
/>
</Report>0 -
Jon,
Here is a solution that eliminates the need for javascript or secondary hidden inputs. I think this achieves the results you are looking for.
The issue is that with any ActionRefresh, Logi will package up the form variables and pass them along within the request. If there is an input named "selFilter-Teams" and a link parameter named "selFilter-Teams", these will be concatenated.
This solution revolves around the idea that Logi automatically refreshes Local datalayers whenever an element with a Local token is refreshed.
You could also filter selFilter-Teams based on the SportID selection so that only the currently selected sport teams are available for selection.
<Report ID="Default">
<DefaultRequestParams selFilter-Sport="1" />
<LocalData>
<DataLayer Type="Static">
<StaticDataRow Sport="Football" SportID="1" Team="Liverpool" TeamID="LIV" />
<StaticDataRow Sport="Football" SportID="1" Team="Man Utd" TeamID="UTD" />
<StaticDataRow Sport="Football" SportID="1" Team="Chelsea" TeamID="CHE" />
<StaticDataRow Sport="Rugby" SportID="2" Team="Ospreys" TeamID="OSP" />
<StaticDataRow Sport="Rugby" SportID="2" Team="Dragons" TeamID="DRA" />
<StaticDataRow Sport="Rugby" SportID="2" Team="Wasps" TeamID="WAS" />
<StaticDataRow Sport="Cricket" SportID="3" Team="Glamorgan" TeamID="GLA" />
<StaticDataRow Sport="Cricket" SportID="3" Team="Middlesex" TeamID="MID" />
<StaticDataRow Sport="Cricket" SportID="3" Team="Surrey" TeamID="SUR" />
<DataLayerLink ID="dllinked" />
<CompareFilter CompareType="=" DataColumn="SportID" ID="cfSportID" CompareValue="@Request.selFilter-Sport~" />
<AggregateColumn AggregateColumn="TeamID" AggregateFunction="Concat" ID="ccTeamID" />
</DataLayer>
</LocalData>
<DefaultRequestParams selFilter-Sport="@Local.SportID~" selFilter-Teams="@Local.ccTeamID~" />
<Body>
<Division ID="divFilters" HtmlDiv="True">
<InputSelectList Caption="Sport:" Class="TextNormal" DefaultValue="@Request.selFilter-Sport~" ID="selFilter-Sport" OptionCaptionColumn="Sport" OptionValueColumn="SportID">
<DataLayer Type="Linked" LinkedDataLayerID="dllinked">
<GroupFilter GroupColumn="Sport" KeepGroupedRows="False" />
</DataLayer>
<EventHandler DhtmlEvent="onchange">
<Action Type="RefreshElement" ElementID="divContent" ID="areContent" />
</EventHandler>
</InputSelectList>
</Division>
<Division ID="divContent" HtmlDiv="True">
<InputCheckboxList Caption="Teams:" CaptionClass="TextBlack ThemeBold" CheckboxListDropdown="True" Class="TextBlack" DropdownButtonClass="form-control" DropdownNoneSelectedCaption="Select Teams" DropdownSelectedCaption="# selected" EnableSearch="False" ID="selFilter-Teams" OptionCaptionColumn="Team" OptionValueColumn="TeamID" Width="600" WidthScale="px" DefaultValue="@Local.ccTeamID~">
<CheckboxListBranch OptionCaptionColumn="Sport" />
<DataLayer Type="Linked" LinkedDataLayerID="dllinked">
<GroupFilter GroupColumn="Sport" Hierarchical="True" KeepGroupedRows="True" />
</DataLayer>
</InputCheckboxList>
</Division>
</Body>
</Report>1 -
That is perfect, thank you very much :) manged to get in working in my proper solution.
0 -
Sorry picked up another issue, if I deselect some options and click refresh on my report it defaults for all items selected as the Default value is the @Local token and not the @Request
0 -
Jon,
Can you post your current Report code or a sample that exhibits this behavior.
0 -
<?xml version="1.0" encoding="utf-8"?>
<Report
ID="Default"
>
<DefaultRequestParams
selFilter-Sport="1"
/>
<LocalData>
<DataLayer
Type="Static"
>
<StaticDataRow
Sport="Football"
SportID="1"
Team="Liverpool"
TeamID="LIV"
/>
<StaticDataRow
Sport="Football"
SportID="1"
Team="Man Utd"
TeamID="UTD"
/>
<StaticDataRow
Sport="Football"
SportID="1"
Team="Chelsea"
TeamID="CHE"
/>
<StaticDataRow
Sport="Rugby"
SportID="2"
Team="Ospreys"
TeamID="OSP"
/>
<StaticDataRow
Sport="Rugby"
SportID="2"
Team="Dragons"
TeamID="DRA"
/>
<StaticDataRow
Sport="Rugby"
SportID="2"
Team="Wasps"
TeamID="WAS"
/>
<StaticDataRow
Sport="Cricket"
SportID="3"
Team="Glamorgan"
TeamID="GLA"
/>
<StaticDataRow
Sport="Cricket"
SportID="3"
Team="Middlesex"
TeamID="MID"
/>
<StaticDataRow
Sport="Cricket"
SportID="3"
Team="Surrey"
TeamID="SUR"
/>
<DataLayerLink
ID="dllinked"
/>
<CompareFilter
CompareType="="
CompareValue="@Request.selFilter-Sport~"
DataColumn="SportID"
ID="cfSportID"
/>
<AggregateColumn
AggregateColumn="TeamID"
AggregateFunction="Concat"
ID="ccTeamID"
/>
</DataLayer>
</LocalData>
<DefaultRequestParams
selFilter-Sport="@Local.SportID~"
selFilter-Teams="@Local.ccTeamID~"
/>
<Body>
<Division
HtmlDiv="True"
ID="divFilters"
>
<InputSelectList
Caption="Sport:"
Class="TextNormal"
DefaultValue="@Request.selFilter-Sport~"
ID="selFilter-Sport"
OptionCaptionColumn="Sport"
OptionValueColumn="SportID"
>
<DataLayer
LinkedDataLayerID="dllinked"
Type="Linked"
>
<GroupFilter
GroupColumn="Sport"
KeepGroupedRows="False"
/>
</DataLayer>
</InputSelectList>
<LineBreak/>
<Label
Caption="Refresh Globally Button"
>
<Action
ElementID="divContent"
ID="actRefresh"
Type="RefreshElement"
/>
</Label>
</Division>
<Division
HtmlDiv="True"
ID="divContent"
>
<LineBreak
LineCount="2"
/>
<InputCheckboxList
Caption="Teams:"
CaptionClass="TextBlack ThemeBold"
CheckboxListDropdown="True"
Class="TextBlack"
DefaultValue="@Local.ccTeamID~"
DropdownButtonClass="form-control"
DropdownNoneSelectedCaption="Select Teams"
DropdownSelectedCaption="# selected"
EnableSearch="False"
ID="selFilter-Teams"
OptionCaptionColumn="Team"
OptionValueColumn="TeamID"
Width="600"
WidthScale="px"
>
<CheckboxListBranch
OptionCaptionColumn="Sport"
/>
<DataLayer
LinkedDataLayerID="dllinked"
Type="Linked"
>
<GroupFilter
GroupColumn="Sport"
Hierarchical="True"
KeepGroupedRows="True"
/>
</DataLayer>
</InputCheckboxList>
<LineBreak/>
<Label
Caption="Refresh Locally Button"
>
<Action
ElementID="divLocalContent"
ID="actRefresh"
Type="RefreshElement"
/>
</Label>
<Division
ID="divLocalContent"
>
<LineBreak
LineCount="5"
/>
<Label
Caption="Local Token: @Local.ccTeamID~"
/>
<LineBreak/>
<Label
Caption="Request Token: @Request.selFilter-Teams~"
/>
</Division>
</Division>
</Body>
<ideTestParams
selFilter-Sport=""
selFilter-Teams=""
/>
</Report>0 -
Posted above, I have added labels to show the difference in the @Local token and the select list @Request token.
I couldn't use the @Request token on the Global Refresh as it is still the original value and then I can't use @Local if you refresh locally as this will bring back all the values regardless what you have checked within the checklist?
Hope that makes sense? :)
0
Please sign in to leave a comment.
Comments
7 comments