Feb 05, 2015, 5:34 PM
[FIXED] [#688] [3.1.0] MultiCombo SortByDisplayField / SortByValueField
I noticed that neither SortByDisplayField nor SortByValueField were working on the MultiCombo.
This override seems to fix it. I don't know if that's the best way to go about it or not.
This override seems to fix it. I don't know if that's the best way to go about it or not.
<%@ Page Language="C#" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>MultiCombo SortByDisplayField</title>
<script type="text/javascript">
Ext.define('GL.overrides.net.MultiCombo', {
override: 'Ext.net.MultiCombo',
onBindStore: function (store, initial) {
this.callParent(arguments);
// add sorting to valueCollection
if (store && (this.sortByDisplayField || this.sortByValueField)) {
this.valueCollection.sort(this.sortByDisplayField ? this.displayField : this.valueField, 'ASC');
}
}
});
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:MultiCombo runat="server" ID="MultiCombo1" SortByDisplayField="true" Width="300">
<Items>
<ext:ListItem Text="Item E" Value="1" />
<ext:ListItem Text="Item D" Value="5" />
<ext:ListItem Text="Item C" Value="3" />
<ext:ListItem Text="Item B" Value="4" />
<ext:ListItem Text="Item A" Value="2" />
</Items>
<SelectedItems>
<ext:ListItem Value="1" />
<ext:ListItem Index="4" />
</SelectedItems>
</ext:MultiCombo>
<br />
<ext:FieldContainer runat="server" Layout="HBoxLayout" Width="300">
<Items>
<ext:TextField runat="server" ID="JsonText" FieldLabel="JSON Value" LabelWidth="80" Flex="1" />
<ext:Button runat="server" Text="Get" Handler="function () { #{JsonText}.setValue(Ext.encode(#{MultiCombo1}.getValue())); }" />
<ext:Button runat="server" Text="Set" Handler="function () { #{MultiCombo1}.setValue(Ext.decode(#{JsonText}.getValue() || '[]')); }" />
</Items>
</ext:FieldContainer>
</form>
</body>
</html>
Last edited by Daniil; Feb 09, 2015 at 11:46 AM.
Reason: [FIXED] [#688] [3.1.0]