Mar 23, 2011, 7:58 AM
[CLOSED] Custom ComboBox loading
Hi,
I have one custom comboBox and I added inside one Store control and my purpose is that I will give one ID and ComboBox will be loaded automaticly by Store control. And when I need to refresh data inside store, I should be able to refresh comboBox or store control in ComboBox. How can I achieve this?
This is my sample code.
I have one custom comboBox and I added inside one Store control and my purpose is that I will give one ID and ComboBox will be loaded automaticly by Store control. And when I need to refresh data inside store, I should be able to refresh comboBox or store control in ComboBox. How can I achieve this?
This is my sample code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ext.Net;
using System.Data;
namespace ExtWebControlLib
{
public class ComboBox : Ext.Net.ComboBox
{
private Store _store=null;
protected Store InnerStore
{
get { return _store; }
set { _store = value; }
}
private int _langID = 1;
public int LangID
{
get { return _langID; }
set { _langID = value; }
}
private DataTable GetRootObjects()
{
DataTable retValue = null;
try
{
int langID = LangID;
retValue = SysMgmWeb_Methods.fn_RootObjects(langID);
}
catch (Exception ex)
{
//Response.Write(ex.Message);
}
return retValue;
}
private void LoadStore()
{
DataTable dtRootObjects = GetRootObjects();
this.InnerStore.DataSource = dtRootObjects;
this.InnerStore.DataBind();
}
void Store_RefreshData(object sender, StoreRefreshDataEventArgs e)
{
LoadStore();
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
InnerStore = new Store();
InnerStore.AutoLoad = true;
InnerStore.AutoDataBind = true;
JsonReader jr = new JsonReader();
jr.IDProperty = "ObjID";
jr.Fields.Add(new RecordField("ObjID"));
jr.Fields.Add(new RecordField("ObjName"));
jr.Fields.Add(new RecordField("ObjType"));
InnerStore.Reader.Add(jr);
InnerStore.RefreshData += new Ext.Net.Store.AjaxRefreshDataEventHandler(Store_RefreshData);
this.Store.Add(InnerStore);
this.ValueField = "ObjID";
this.DisplayField = "ObjName";
}
}
}
Last edited by Daniil; Mar 24, 2011 at 10:23 AM.
Reason: [CLOSED]