PDA

View Full Version : [CLOSED] MultiCombo



softmachine2011
Jul 31, 2012, 2:09 PM
Hi,

I'm older version I used this:


multiCombo.getText()

Is this equivalent right now? Or there is any other method or property to use it?

multiCombo.rawValue

In the same way, if I have something like this example


<ext:MultiCombo ID="cmbTest" runat="server" Width="200" FieldLabel="Sample" LabelAlign="Top">
<Items>
<ext:ListItem Text="Text 1" Value="1" />
<ext:ListItem Text="Text 2" Value="2" />
<ext:ListItem Text="Text 3" Value="3" />
<ext:ListItem Text="Text 4" Value="4" />
</Items>
</ext:MultiCombo>


If I selected the items in thsi order 4,2,3,1 control shows me in the order I selected (Text 4, Text 2, Text 3, Text 1) instead of in order marked in list/store (Text 1, Text 2, Text 3, Text 4)

Daniil
Jul 31, 2012, 4:49 PM
Hi,

I can suggest the following solution.

var combo = App.MultiCombo1,
value = combo.getRawValue(),
sortedValue = value.split(combo.delimiter).sort().join();

softmachine2011
Aug 01, 2012, 6:49 AM
Hi,

With this I have the value sorted well but I meant that in input field of multicombo appears unordered instead of appear ordered like in v1.x

This would be fixed in v2.1? Or you doesn't consider a bug?

softmachine2011
Aug 01, 2012, 7:17 AM
Related with my other post http://forums.ext.net/showthread.php?20179-CLOSED-MultiCombo-selection-via-script

I tried to use with revision 4239



multiCombo.setValue(['1', '2']);


And not works, it show 1,2 in input field instead of text that correspond. And also doesn't check any item.

In the same way, I'm trying to load multicombo value with FormPanel.form.loadRecord(record) and record data has a property that corresponds with multicombo and the result is the same.

Could you provide me the format that multicombo expect in setValue and/or loadRecord of the form?

Daniil
Aug 01, 2012, 9:34 AM
With this I have the value sorted well but I meant that in input field of multicombo appears unordered instead of appear ordered like in v1.x

This would be fixed in v2.1? Or you doesn't consider a bug?

Got it. Well, I would prefer to don't consider it a bug. Just the change in the behavior. Personally, I like the new behavior more.

Though, sure, it has been changed since Ext.NET v1 and can annoy.

Probably, it would be best to have an option to get the two behaviors switching that option.

For now, I can suggest the following solution. Though I am not 100% sure it won't cause any background effect, but almost sure.

Example

Ext.form.field.ComboBox.override({
onListSelectionChange: function(list, selectedRecords) {
var me = this,
isMulti = me.multiSelect,
hasRecords = selectedRecords.length > 0;

/* Workaround */
Ext.Array.sort(selectedRecords, function (r1, r2) {
return r1.get(me.displayField) > r2.get(me.displayField)
});
/* End of Workaround */

// Only react to selection if it is not called from setValue, and if our list is
// expanded (ignores changes to the selection model triggered elsewhere)
if (!me.ignoreSelection && me.isExpanded) {
if (!isMulti) {
Ext.defer(me.collapse, 1, me);
}
/*
* Only set the value here if we're in multi selection mode or we have
* a selection. Otherwise setValue will be called with an empty value
* which will cause the change event to fire twice.
*/
if (isMulti || hasRecords) {
me.setValue(selectedRecords, false);
}
if (hasRecords) {
me.fireEvent('select', me, selectedRecords);
}
me.inputEl.focus();
}
}
});


Related with my other post http://forums.ext.net/showthread.php?20179-CLOSED-MultiCombo-selection-via-script

I tried to use with revision 4239



multiCombo.setValue(['1', '2']);


And not works, it show 1,2 in input field instead of text that correspond. And also doesn't check any item.


I just tested the example in that thread, it appears to be working correctly. Did you test with that example? If no, please provide a new one.

softmachine2011
Aug 01, 2012, 11:06 AM
Got it. Well, I would prefer to don't consider it a bug. Just the change in the behavior. Personally, I like the new behavior more.

Though, sure, it has been changed since Ext.NET v1 and can annoy.

Probably, it would be best to have an option to get the two behaviors switching that option.
.

It would be this option in a future v2.1 of Ext.NET?




I just tested the example in that thread, it appears to be working correctly. Did you test with that example? If no, please provide a new one.

Hi,

It seems that don't work with items loaded by an store, here is an example



<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
this.Store1.DataSource = new object[]
{
new object[]{1,"AL", "Alabama", "The Heart of Dixie", 5.99},
new object[] {2, "AK", "Alaska", "The Land of the Midnight Sun", 5.99},
new object[] {3, "AZ", "Arizona", "The Grand Canyon State", 5.99},
new object[] {4, "AR", "Arkansas", "The Natural State", 5.99}
};

this.Store1.DataBind();
}
</script>

<ext:MultiCombo ID="cmbTest" runat="server" Width="200" FieldLabel="Sample" LabelAlign="Top" ValueField="id" DisplayField="state">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model runat="server" IDProperty="id">
<Fields>
<ext:ModelField Name="id" Type="Int" />
<ext:ModelField Name="abbr" Type="String" />
<ext:ModelField Name="state" Type="String" />
<ext:ModelField Name="nick" Type="String" />
<ext:ModelField Name="price" Type="Float" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:MultiCombo>
<ext:Button runat="server">
<Listeners>
<Click Handler="cmbTest.setValue(['1', '2']);" />
</Listeners>
</ext:Button>

Daniil
Aug 01, 2012, 12:00 PM
It would be this option in a future v2.1 of Ext.NET?

I don't know yet it will be or not. I will notify you.




It seems that don't work with items loaded by an store, here is an example



<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
this.Store1.DataSource = new object[]
{
new object[]{1,"AL", "Alabama", "The Heart of Dixie", 5.99},
new object[] {2, "AK", "Alaska", "The Land of the Midnight Sun", 5.99},
new object[] {3, "AZ", "Arizona", "The Grand Canyon State", 5.99},
new object[] {4, "AR", "Arkansas", "The Natural State", 5.99}
};

this.Store1.DataBind();
}
</script>

<ext:MultiCombo ID="cmbTest" runat="server" Width="200" FieldLabel="Sample" LabelAlign="Top" ValueField="id" DisplayField="state">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model runat="server" IDProperty="id">
<Fields>
<ext:ModelField Name="id" Type="Int" />
<ext:ModelField Name="abbr" Type="String" />
<ext:ModelField Name="state" Type="String" />
<ext:ModelField Name="nick" Type="String" />
<ext:ModelField Name="price" Type="Float" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:MultiCombo>
<ext:Button runat="server">
<Listeners>
<Click Handler="cmbTest.setValue(['1', '2']);" />
</Listeners>
</ext:Button>


You bind numbers into the Store, so, you should use numbers, not strings, in the setValue method as well.

Daniil
Aug 01, 2012, 1:03 PM
We have added the SortByDisplayField property. True to sort selected items by DisplayField. Defaults to false.

SVN revision #4240 (2.1 branch).

Thanks for the report.

softmachine2011
Aug 01, 2012, 1:19 PM
You bind numbers into the Store, so, you should use numbers, not strings, in the setValue method as well.

Ok thanks, it works setValue without quotes.



We have added the SortByDisplayField property. True to sort selected items by DisplayField. Defaults to false.

SVN revision #4240 (2.1 branch).

Thanks for the report.

Thanks for it, I'll update to it.

softmachine2011
Aug 01, 2012, 1:40 PM
I try rev 4240 but new property doesn't apply.

In changes I didn't appreciate when the override or call to new function is do it. It could miss this in source?

Daniil
Aug 01, 2012, 1:45 PM
Did you not forget to re-build Ext.NET?

softmachine2011
Aug 01, 2012, 1:56 PM

Daniil
Aug 01, 2012, 2:01 PM
Please provide a test sample.

softmachine2011
Aug 01, 2012, 2:14 PM

Daniil
Aug 01, 2012, 3:14 PM
If I select values manually it don't order well neither.

It orders for me well.


As I see in commited source the new method that order text values isn't called anywhere. Did you commited all code?

I didn't take it in the account at all.

Please update to the revision #4241 and re-test.

softmachine2011
Aug 02, 2012, 7:32 AM
nope, tested in rev. 4243 and selecting manually or with setValue method in the example that I writed doesn't order well with this property set to true.

Could you provide me your test example to find any difference?

softmachine2011
Aug 02, 2012, 7:41 AM

Daniil
Aug 02, 2012, 10:20 AM
Could you provide me your test example to find any difference?

Just your code.

Well, I was able to reproduce the issue under IE only, it works correctly in FireFox and Chrome. Can you confirm?


As I can see, if you perform this it sorts records correctly


matchedRecords.sort();


I think it gives an unpredictable result.

softmachine2011
Aug 02, 2012, 10:43 AM
Yes I was in IE9 exactly and in Chrome 21 works well.

Daniil
Aug 02, 2012, 10:48 AM
My fault, a sort function must return -1, 0, 1, not just false or true.

Please update from SVN.

Apologize for the inconvenience.

softmachine2011
Aug 02, 2012, 11:56 AM
Don't worry.

It works now, thanks for all.