public ActionResult LoadNotes(int id) { string notes = string.Empty; foreach (object fish in FishCatalog.GetData()) { if ((int)DataBinder.Eval(fish, "ID") == id) { notes = (string)DataBinder.Eval(fish, "Notes"); break; } } return(TreeListExtension.GetCustomDataCallbackResult(notes)); }
public TreeListExtension TreeList(Action <LOSTreeListSettings> method) { Action <LOSTreeListSettings> tmpMethod = (Action <LOSTreeListSettings>)method.Clone(); var tmpInstance = new LOSTreeListSettings(); tmpInstance.Columns.IsInit = true; method.Invoke(tmpInstance); if (tmpInstance.DataSource == null || !tmpInstance.DataSource.GetType().IsGenericType) { throw new InvalidOperationException("Cannot bind data source without generic type"); } var modelType = tmpInstance.DataSource.GetType().GetGenericArguments()[0]; var settingInstance = new LOSTreeListSettings(ModelExtensionsHelper.GetModelMetadataForModel(modelType), HtmlHelper.ViewContext); tmpMethod?.Invoke(settingInstance); var treeList = new TreeListExtension(settingInstance.Settings, HtmlHelper.ViewContext); treeList = treeList.Bind(settingInstance.DataSource); return(treeList); }