PDA

View Full Version : [CLOSED] Cascading combo box Fuctionality.



alscg
Mar 04, 2013, 11:16 AM
Hi,

In below code I have Model in which there are two list DataCategory List and another is DataType list. On selection of Data category I want to have Data Type.With the example shown in the link http://mvc.ext.net/#/Form_ComboBox/Ajax_Linked_Combos/
there is a call which pull the data and fill the combo but in my case I already have the data into the DataType list.

So I just need to write the condition on the list.I tried to write the condition inside DataSource property of the DataType combo.
but here App.DataCategory.getValue() is not working as App is not recognized here. Can you help in getting the value of DataCategory Combo in this condition.




Html.X().ComboBoxFor(ad=>ad.DataCategoryId)
.ID("DataCategory")
.Padding(5)
.Editable(false)
.DisplayField("Data_Category_Desc")
.ValueField("Data_Category_Id")
.QueryMode(DataLoadMode.Local)
.TriggerAction(TriggerAction.All)
.SelectOnFocus(true)
.EmptyText("Select Category")
.Listeners(ls =>
ls.Select.Handler = "App.DataType.clearValue(); App.DataType.getStore().load())")
.Items((from dataCategory in Model.DataCategoryList select new Ext.Net.ListItem
{ Text = dataCategory.Data_Category_Desc, Value = dataCategory.Data_Category_Id.ToString() })
)

Html.X().ComboBoxFor(um => um.DataTypeId)
.ID("DataType")
.DisplayField("Data_Type_Desc")
.ValueField("Data_Type_Id")
.EmptyText("Loading...")
.ValueNotFoundText("Loading...")
.Store(Html.X().Store()
.ID("CmbStore")
.AutoLoad(false)
.Model(Html.X().Model()
.IDProperty("Data_Type_Id")
.Fields(
new ModelField("Data_Type_Id", ModelFieldType.String) { Mapping = "Data_Type_Id" },
new ModelField("Data_Type_Desc", ModelFieldType.String) { Mapping = "Data_Type_Desc" }
)
)
.DataSource(Model.DataTypeList.Where(um => um.Data_Category_Id == 1))
)


MODEL:- AddNewDataFileDTO



public class AddNewDataFileDTO
{
public int DataCategoryId { get; set; }
public string DataCategory { get; set; }
public int DataTypeId { get; set; }
public string DataType { get; set; }

public List<DataCategoryDTO> DataCategoryList { get; set; }
public List<DataTypeDTO> DataTypeList { get; set; }
}

Daniil
Mar 04, 2013, 2:38 PM
Hi @alscg,

Do you want to bind data this way initially or on user choice (I mean selecting an item by a user)?

If the first, I think you should get a key directly from a Model.

If the second, I think it is not possible, because the view is already rendered. You will have to reload a Store as it is done in the example you mentioned.