Nov 12, 2009, 7:12 AM
grid panel extension problem
[Xtype("multigroupgridpanel")]
[InstanceOf(ClassName = "Ext.ux.MultiGroupingPanel")]
[ClientScript(Type = typeof(MultiGroupingPanel), FilePath = "/ux/extensions/multigrouping/multigrouping.js", WebResource = "Coolite.Ext.Web.Build.Resources.Coolite.ux.extensions.multigrouping.multigrouping.js")]
[Designer(typeof(EmptyDesigner))]
public class MultiGroupingPanel : GridPanel
{
protected override void OnBeforeClientInit(Observable sender)
{
base.OnBeforeClientInit(sender);
this.CheckColumns();
if (this.SelectionMemoryProxy && string.IsNullOrEmpty(this.MemoryIDField) && !string.IsNullOrEmpty(this.StoreID))
{
Store store = ControlUtils.FindControl(this, this.StoreID) as Store;
if (store != null && store.Reader.Count > 0)
{
string id = store.Reader.Reader.ReaderID;
if (!string.IsNullOrEmpty(id))
{
this.MemoryIDField = id;
}
}
}
}
private void CheckColumns()
{
string plugins = this.GetColumnPlugins();
if (plugins.Length > 2)
{
this.CustomConfig.Add(new ConfigItem("columnPlugins", plugins, ParameterMode.Raw));
}
}
private string GetColumnPlugins()
{
StringBuilder sb = new StringBuilder("[");
for (int i = 0; i < this.ColumnModel.Columns.Count; i++)
{
CommandColumn cmdCol = this.ColumnModel.Columns[i] as CommandColumn;
ImageCommandColumn imgCmdCol = this.ColumnModel.Columns[i] as ImageCommandColumn;
Column column = this.ColumnModel.Columns[i] as Column;
if (column != null && column.Commands.Count > 0 && imgCmdCol == null)
{
this.ScriptManager.RegisterClientStyleInclude("Coolite.Ext.Web.Build.Resources.Coolite.ux.plugins.commandcolumn.commandcolumn.css");
continue;
}
if (cmdCol != null || imgCmdCol != null)
{
sb.Append(i + ",");
this.ScriptManager.RegisterClientStyleInclude("Coolite.Ext.Web.Build.Resources.Coolite.ux.plugins.commandcolumn.commandcolumn.css");
continue;
}
CheckColumn cc = this.ColumnModel.Columns[i] as CheckColumn;
if (cc != null && cc.Editable)
{
sb.Append(i + ",");
continue;
}
}
if (sb[sb.Length - 1] == ',')
{
sb.Remove(sb.Length - 1, 1);
}
sb.Append("]");
return sb.ToString();
}
protected override void OnAfterClientInit(Observable sender)
{
base.OnAfterClientInit(sender);
CheckAutoExpand();
}
private void CheckAutoExpand()
{
if (!string.IsNullOrEmpty(this.AutoExpandColumn))
{
bool found = false;
foreach (ColumnBase column in this.ColumnModel.Columns)
{
if (column.ColumnID == this.AutoExpandColumn)
{
found = true;
break;
}
}
if (!found)
{
throw new ArgumentException(string.Concat("The auto expand Column with ID='", this.AutoExpandColumn, "' is not found!"));
}
}
}
protected override void PageLoadComplete(object sender, EventArgs e)
{
base.PageLoadComplete(sender, e);
//Here is we must add view templates because InnerObservable incorrect hosts inner controls
if (this.View.View != null)
{
this.Controls.Add(this.View.View.Templates.Header);
}
}
protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
{
bool result = base.LoadPostData(postDataKey, postCollection);
string val = postCollection[string.Concat(this.ClientID, "_SM")];
if (val != null && this.SelectionModel.Primary != null)
{
JsonSerializer serializer = new JsonSerializer();
serializer.MissingMemberHandling = MissingMemberHandling.Ignore;
StringReader sr = new StringReader(val);
if (this.SelectionModel.Primary is RowSelectionModel)
{
SelectedRowCollection ids = (SelectedRowCollection)serializer.Deserialize(sr, typeof(SelectedRowCollection));
(this.SelectionModel.Primary as RowSelectionModel).SetSelection(ids);
}
else if (this.SelectionModel.Primary is CellSelectionModel)
{
SelectedCellSerializable cell = (SelectedCellSerializable)serializer.Deserialize(sr, typeof(SelectedCellSerializable));
if (cell != null)
{
CellSelectionModel sm = this.SelectionModel.Primary as CellSelectionModel;
sm.SelectedCell.RowIndex = cell.RowIndex;
sm.SelectedCell.ColIndex = cell.ColIndex;
sm.SelectedCell.RecordID = cell.RecordID;
sm.SelectedCell.Name = cell.Name;
sm.SelectedCell.Value = cell.Value;
}
}
}
return result;
}
}
i have this multigrouping grid panel which allows for multiple grouping in a grid panel... my problem now is that i cannot get the selectedRows of its selection model... if you will check the selectionmodel collection of the grid panel, there is selectionmodel item, but the problem is if i do selectionModel..SelectedRows... it is always empty even if i have a row selected... please help