Oct 05, 2011, 7:44 AM
SelectedRows always 0.
[update]
Nobody out there with same prob or some idea to solve it?
[/update]
Hi
I have a problem with getting selected rows from a GridPanel. I do all the coding in C# and everything works fine except getting these selected rows.
The GridPanel is nested inside a Window which is initalized at Page_Load.I'd like to fetch selectedrows with a button's DirectClick.
Some of my code:
But selected rows is always empty. What did I wrong?
Thanks in advance
cu
Michael
Nobody out there with same prob or some idea to solve it?
[/update]
Hi
I have a problem with getting selected rows from a GridPanel. I do all the coding in C# and everything works fine except getting these selected rows.
The GridPanel is nested inside a Window which is initalized at Page_Load.I'd like to fetch selectedrows with a button's DirectClick.
Some of my code:
public partial class UserAdmin : System.Web.UI.Page
{
Window wndEditUser, wndEditRight, wndSelectRight, wndSelectRightFlat;
GridPanel UserGrid;
Ext.Net.Panel RightsPanel;
protected void Page_Load(object sender, EventArgs e)
{
UserGrid = getUserGrid();
RightsPanel = getRightsPanel();
wndEditUser = buildWndEdituser();
wndEditRight = buildWndEditRight();
//wndSelectRight = buildWndSelectRight();
wndSelectRightFlat = buildWndSelectRightFlat();
BorderLayout MainVpLayout = new BorderLayout();
MainVpLayout.North.Items.Add(getNorthPanel());
MainVpLayout.Center.Items.Add(getCenterPanel());
MainVpLayout.West.Items.Add(getWestPanel());
Viewport MainVp = new Viewport();
MainVp.ID = "MainViewport";
MainVp.Items.Add(MainVpLayout);
this.Controls.Add(MainVp);
this.Controls.Add(wndEditUser);
this.Controls.Add(wndEditRight);
//this.Controls.Add(wndSelectRight);
this.Controls.Add(wndSelectRightFlat);
}
private Window buildWndSelectRightFlat()
{
GridPanel rightsGP = new GridPanel();
rightsGP = getAllRightsGrid();
Toolbar tb = new Toolbar();
Ext.Net.Button btnOk = new Ext.Net.Button();
btnOk.Text = "speicher";
btnOk.ID = "btnOk_wndSelectRightFlat";
btnOk.Icon = Icon.Accept;
btnOk.DirectClick += new ComponentDirectEvent.DirectEventHandler(btnOk_DirectClick);
Ext.Net.Button btnCancel = new Ext.Net.Button("abbrechen", "#{wndSelectRightFlat}.hide()");
btnCancel.Icon = Icon.Decline;
tb.Items.Add(new ToolbarFill());
tb.Items.Add(btnOk);
tb.Items.Add(btnCancel);
Window w = new Window();
w.Hidden = true;
w.CloseAction = CloseAction.Hide;
w.ID = "wndSelectRightFlat";
w.Modal = true;
w.Height = 300;
w.Width = 500;
w.Resizable = true;
w.Layout = "fit";
w.CustomConfig.AddRange(cic);
w.Add(rightsGP);
w.BottomBar.Add(tb);
return w;
}
void btnOk_DirectClick(object sender, DirectEventArgs e)
{
//(FindControl("wndSelectRightFlat") as Window).Hide();
//RowSelectionModel rsm = new RowSelectionModel();
RowSelectionModel rsm = (FindControl("AllRightsGrid") as GridPanel).SelectionModel.Primary as RowSelectionModel;
//rsm.SelectAll();
X.Msg.Alert("Submit", rsm.SelectedRows.Count.ToString()).Show();
}
private GridPanel getAllRightsGrid()
{
SqlDataSource ds = new SqlDataSource();
ds.ConnectionString = ConfigurationManager.ConnectionStrings["AKV_ConnectionString"].ConnectionString;
ds.SelectCommand = "EXEC [metadata].[perm_get_all_rights_flat]";
JsonReader reader = new JsonReader();
reader.Fields.Add("right_id");
reader.Fields.Add("cname");
reader.Fields.Add("name");
reader.Fields.Add("display_name");
Store store = new Store();
store.ID = "AllRightsGridStore";
store.DataSource = ds;
store.Reader.Add(reader);
if (!X.IsAjaxRequest)
{
store.DataBind();
}
Column col;
ColumnCollection cc = new ColumnCollection();
col = new Column();
col.Header = "Right ID";
col.ColumnID = "right_id";
col.DataIndex = "right_id";
cc.Add(col);
col = new Column();
col.Header = "cname";
col.ColumnID = "cname";
col.DataIndex = "cname";
cc.Add(col);
col = new Column();
col.Header = "name";
col.ColumnID = "name";
col.DataIndex = "name";
cc.Add(col);
col = new Column();
col.Header = "display_name";
col.ColumnID = "display_name";
col.DataIndex = "display_name";
cc.Add(col);
RowSelectionModel sm = new RowSelectionModel();
//sm.ID = "rsmtest";
//sm.Listeners.RowSelect.Handler = "alert( rowIndex )";
GridPanel gp = new GridPanel();
gp.ColumnModel.Columns.AddRange(cc);
gp.SelectionModel.Add(sm);
gp.Title = "Rights";
gp.ID = "AllRightsGrid";
gp.LoadMask.ShowMask = true;
gp.Store.Add(store);
return gp;
}
Inside btnOk_DirectClick I'm able to fetch the RowSelectionModelRowSelectionModel rsm = (FindControl("AllRightsGrid") as GridPanel).SelectionModel.Primary as RowSelectionModel;
I checked rsm.ID to be sure having the right selection model. Even rsm.SelectAll()
works fine.But selected rows is always empty. What did I wrong?
Thanks in advance
cu
Michael
Last edited by mjbohn; Oct 07, 2011 at 5:02 AM.