[CLOSED] X.MultiCombo() in Grid

  1. #1

    [CLOSED] X.MultiCombo() in Grid

    Hi, i am using a X.MultiCombo() in grid. While populating data in the grid store i am setting the values as comma separated string of IDs like - "1,2". But the items are not getting selected in the MultiCombo, rather "1,2" is coming as display on the MultiCombo.

    Can you please guide me to resolve this -

    X.GridPanel()
    	.ID("gridSelected")
    	.Width(470)
    	.Height(275)
    	.Title("Selected Programs")
    	.Margins("2 2 2 2")
    	.Store(X.Store()
    		.ID("selectedStore")
    		.Model(X.Model()
    			.Fields(
    				new ModelField("ProgramID", ModelFieldType.String) { Mapping = "ProgramID" },
    				new ModelField("ProgramName", ModelFieldType.String) { Mapping = "ProgramName" },
    				new ModelField("ProgramTypeName", ModelFieldType.String) { Mapping = "ProgramTypeName" },
    				new ModelField("ProgramCategoryName", ModelFieldType.String) { Mapping = "ProgramCategoryName" },
    				new ModelField("ShiftsAssociated", ModelFieldType.String) { Mapping = "ShiftsAssociated" }
    			)
    		)
    	)
    	.ColumnModel(
    		X.Column().Text("ID").DataIndex("ProgramID").Hidden(true),
    		X.Column().Text("Name").DataIndex("ProgramName").Flex(1),
    		X.ComponentColumn()
    			.Editor(true)
    			.DataIndex("ShiftsAssociated")
    			.Text("Shift")
    			.Component(X.MultiCombo()
    				.Store(
    					X.Store()
    					.Model(X.Model()
    						.IDProperty("ID")
    						.Fields(
    							new ModelField("ShiftID", ModelFieldType.Int) { Mapping = "ShiftID" },
    							new ModelField("ShiftName", ModelFieldType.String) { Mapping = "ShiftName" }
    						)
    					)
    					.DataSource(Model.ShiftList)
    				)
    				.DisplayField("ShiftName")
    				.ValueField("ShiftID")
    			),
    		X.Column().Text("Type").DataIndex("ProgramTypeName").Width(60),
    		X.Column().Text("Category").DataIndex("ProgramCategoryName").Width(60)
    	)
    	.SelectionModel(X.RowSelectionModel().Mode(SelectionMode.Multi))
    Last edited by fabricio.murta; Feb 28, 2015 at 4:38 PM. Reason: [CLOSED]
  2. #2
    Hello @barnali!

    I couldn't find in the code you provided the part you were populating the combo boxes. I can't think in much but provide you with an example using MultiCombo so you can base your code on it.

    Maybe you could also use that example I'm going to point you in order to build a simple code sample highlighting how you populate the MultiCombo so that we can reproduce and advice you.

    Ext.NET example: MultiCombo

    As an additional hint, you can select several items by their IDs by using setValue. On the above example, a javascript of selecting two items in the first checkbox would be:
    App.ctl05.setValue([1, 2])
    The equivalent in code behind would be something like this:
    ctl05.SetValue(new[] { 2, 3 });
    I hope this helps! Share a working sample with us if the tips above does not help at all. I'm sure we can get it working.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    My Multi Combo is a X.ComponentColumn in the grid, So I'm not populating the value in the combo manually. I am populating the store on which the grid bind.
  4. #4
    Hello @barnali!

    I can't seem to find in the code you provided how you are providing values to the stores of the multicombos.

    I believe you are doing something like this:
    App.ctl05.store.add([{field1: 'X', field2: 'Item X'}]);
    For the example I provided you with in my last post (MultiCombo), this command, at javascript console side, will add one entry to the combo box.

    I believe we could help you better if you provided us a simple code sample reproducing your scenario. If you are willing to give it a try, please follow these guidelines below:
    - Forum Guidelines For Posting New Topics
    - More information required
    - How to prepare a sample

    We will be more than eager to give you an accurate solution for your problem!
    Fabrício Murta
    Developer & Support Expert
  5. #5
    I think i could not make you understand my problem

    1. My MultiCombo is ComponentColumn of grid "gridSelected".
    2. MultiCombo store is populated with .DataSource(Model.ShiftList)

    and the grid store is populated as follows

    App.direct.loadRuleSelectedCourses(sessionId, instituteId, {
                                    success: function (result) {
                                        App.gridSelected.getStore().loadData(result.data);
                                    }
                                });
    When I do this, items in the MultiCombo is not getting selected.

    Hope i could make you understand my problem.
    Last edited by barnali; Feb 27, 2015 at 1:32 AM.
  6. #6
    Hello, @barnali!

    Sorry, it seems the .DataSource(Model.ShiftList) is right the line that breaks the code here. I can't even render the page if I don't comment that line out. I'm still not sure how you wanted it to work, or how it is not null nor breaks the code on your side.
    Fabrício Murta
    Developer & Support Expert
  7. #7
    Hello, @Barnali!

    I talked to @daniil about the issue and he suggested that the issue might really be just the way you are passing the values, like I pointed with setValue() above. Be it in code behind, be it in javascript, please pass the values as an array rather than a CSV.

    I mean, in JavaScript, pass the values as [1, 2] instead of "1,2".
    In code behind, values as new[] { 1, 2 } instead of "1,2".

    Does this help you figure out the issue?

    If not, let us know. Again, the ideal scenario would be the one where you provided a fully working sample, with the grid being built from dummy data, as instructed in the previous posts.
    Last edited by fabricio.murta; Feb 27, 2015 at 7:53 PM.
    Fabrício Murta
    Developer & Support Expert
  8. #8
    Could make it work!!! Updating the post for others' benefit -

    Lesson learnt -

    If you have Multicombo as a component column in a grid, if you are passing values as comma separated string like - "1,2" in the grid store ModelField, Use a converted in the ModelField and return value.split(",")

    Thanks for the help.

    Please make it as solved.

Similar Threads

  1. [CLOSED] Add a MultiCombo box as a column in a grid panel
    By jainanki in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 18, 2014, 9:19 AM
  2. Replies: 1
    Last Post: May 06, 2014, 5:22 AM
  3. MultiCombo and IE8
    By Birgit in forum 2.x Help
    Replies: 1
    Last Post: Dec 07, 2012, 9:15 AM
  4. [CLOSED] Multicombo in gridPanel
    By imaa in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Nov 15, 2012, 1:28 PM
  5. Select all in MultiCombo
    By skrishnasamy in forum 1.x Help
    Replies: 0
    Last Post: Aug 12, 2010, 7:00 AM

Posting Permissions