Skip to content

Commit

Permalink
Add sorting to widget configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
lindski committed Nov 30, 2015
1 parent f014716 commit aaf6de9
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
Binary file modified dist/BootstrapMultiSelectForMendix.mpk
Binary file not shown.
34 changes: 33 additions & 1 deletion src/BootstrapMultiSelectForMendix/BootstrapMultiSelect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,39 @@ iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lD
<caption>Data constraint</caption>
<category>Data source</category>
<description>Optional constraint to filter the available options</description>
</property>
</property>
<property key="sortContainer" type="object" isList="true" required="false">
<caption>Sort order</caption>
<category>Data source</category>
<description>The sort order of the objects</description>
<properties>
<property key="sortAttribute" type="attribute" isPath="optional" pathType="reference" entityProperty="../dataAssociation">
<caption>Attribute</caption>
<category>Data source</category>
<description>An attribute to sort on</description>
<attributeTypes>
<attributeType name="AutoNumber"/>
<attributeType name="Boolean"/>
<attributeType name="Currency"/>
<attributeType name="DateTime"/>
<attributeType name="Enum"/>
<attributeType name="Float"/>
<attributeType name="Integer"/>
<attributeType name="Long"/>
<attributeType name="String"/>
</attributeTypes>
</property>
<property key="sortOrder" type="enumeration" defaultValue="asc">
<caption>Order</caption>
<category>Data source</category>
<description>The order in which to sort</description>
<enumerationValues>
<enumerationValue key="asc">Ascending</enumerationValue>
<enumerationValue key="desc">Descending</enumerationValue>
</enumerationValues>
</property>
</properties>
</property>
<property key="showLabel" type="boolean" defaultValue="true">
<caption>Show Label</caption>
<category>Display</category>
Expand Down
13 changes: 10 additions & 3 deletions src/BootstrapMultiSelectForMendix/widget/BootstrapMultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
========================
@file : BootstrapMultiSelect.js
@version : 1.3
@version : 1.5
@author : Iain Lindsay
@date : Thur, 24 Sep 2015 19:42:00 GMT
@date : Mon, 30 Nov 2015 11:57:00 GMT
@copyright : AuraQ Limited 2015
@license : Apache v2
Expand Down Expand Up @@ -76,6 +76,7 @@ require({
_$alertdiv: null,
_$combo: null,
_comboData : [],
_sortParams : [],

constructor: function () {
this._handles = [];
Expand All @@ -87,6 +88,12 @@ require({
this._reference = this.dataAssociation.split('/')[0];
this._labelAttribute = this.labelAttribute.split('/')[2];

// create our sort order array
for(var i=0;i<this.sortContainer.length;i++) {
var item = this.sortContainer[i];
this._sortParams.push([item.sortAttribute, item.sortOrder]);
}

// make sure we only select the control for the current id or we'll overwrite previous instances
var selector = '#' + this.id + ' select.multiSelect';
this._$combo = $(selector);
Expand Down Expand Up @@ -204,7 +211,7 @@ require({
mx.data.get({
xpath: xpath,
filter: {
sort: [[this._labelAttribute, "asc"]],
sort: this._sortParams,
offset: 0
},
callback: lang.hitch(this, this._processComboData)
Expand Down
Binary file modified test/Test.mpr
Binary file not shown.
Binary file modified test/widgets/BootstrapMultiSelectForMendix.mpk
Binary file not shown.

0 comments on commit aaf6de9

Please sign in to comment.