Quite new to MVC and kendo and was wondering if there was a way to prevent panelbar from creating duplicate items and whats the best method to achieve this.
Here is my panelbar markup:
Here is my class markup for the model:
And here is my controller action:
Is there anyway in the controller action or actual panelbar markup to select DISTINCT category? My model returns multiple rows which could have different or the same category. Or is there a way I can check if the item with certain text exists already and not create it?
Also am I going about this the wrong way and do I need to have a separate model just for categories?
Here is my panelbar markup:
@(Html.Kendo() .PanelBar() .Name("panelbar") .HtmlAttributes(new { style = "width:200px" }) .ExpandAll(true) .BindTo(Model, (Kendo.Mvc.UI.Fluent.NavigationBindingFactory<PanelBarItem> mappings) => { mappings.For<QueryModel>(binding => { binding.ItemDataBound((panelitem, modelitem) => { panelitem.Text = modelitem.category; }); }); }) )Here is my class markup for the model:
public class QueryModel { public string category { get; set; } public string controlID { get; set; } public string controlType { get; set; } public System.Nullable<int> multiplier { get; set; } public string caption { get; set; } public string dropdownSQL { get; set; } public string columnSQL { get; set; } public string sortorder { get; set; } public string tooltip { get; set; } }And here is my controller action:
public ActionResult Query() { QueryModel querydata = new QueryModel(); var results = from s in dbContext.T223_Searches join sd in dbContext.T224_SearchDetails on s.KeySearch equals sd.KeySearch join sc in dbContext.T225_SearchCategories on sd.KeyCategory equals sc.KeyCategory where sd.KeySearch == 3 orderby sd.SortOrder select new QueryModel { category = sc.Description, controlID = sd.ControlID, controlType = sd.ControlType, multiplier = sd.Multiplier, caption = sd.Caption, dropdownSQL = sd.DDLSQL, columnSQL = sd.SQLColumn, tooltip = sd.ToolTip }; return View("Query", results.ToList()); }Is there anyway in the controller action or actual panelbar markup to select DISTINCT category? My model returns multiple rows which could have different or the same category. Or is there a way I can check if the item with certain text exists already and not create it?
Also am I going about this the wrong way and do I need to have a separate model just for categories?