Sep 05, 2014, 3:05 PM
Thanks for your reply,
Now both code is working.
Now both code is working.
@X.ResourceManager()
@(
Html.X().GridPanel()
.ID("targetgrid")
.Store(
Html.X().Store()
.DataSource(ViewBag.loadgrid)
.Model
(
X.Model()
.Fields
(
X.ModelField().Name("reqid").Type(ModelFieldType.String)
)
)
)
.ColumnModel(
Html.X().Column().DataIndex("reqid").Text("Common Name 1").Flex(1)
)
.SelectionModel(
X.CheckboxSelectionModel()
.Mode(SelectionMode.Multi)
)
)
@(
X.Window()
.ID("Window1")
.Height(500)
.Weight(1200)
.Hidden(true)
.Listeners(l => { l.Show.Handler = "App.sourcegrid.getStore().reload();"; })
.Items
(
Html.X().GridPanel()
.ID("sourcegrid")
.Weight(1200)
.Layout(LayoutType.Fit)
.Store(
Html.X().Store()
.Model
(
X.Model()
.Fields
(
X.ModelField().Name("reqid").Type(ModelFieldType.String)
)
)
.ServerProxy
(
X.AjaxProxy()
.Url("/Copy_Grid_to_grid/grid2data")
.Reader(X.JsonReader().Root("data"))
)
)
.ColumnModel(
Html.X().Column().DataIndex("reqid").Text("Common Name 1").Flex(1)
)
.SelectionModel
(
X.CheckboxSelectionModel()
.Mode(SelectionMode.Multi)
)
.Plugins(
Html.X().RowExpander()
.ID("RowExpander1")
.SingleExpand(false)
.Listeners(l =>
{
l.Expand.Handler = @"var rowExpander = this;
rowExpander.getComponent(record).getStore().reload({
params: {
reqid: record.data.reqid
},
callback: function() {
Ext.defer(rowExpander.cmp.doLayout, 1, rowExpander.cmp);
}
});";
})
.Component
(
Html.X().GridPanel()
.ID("regrid")
.Header(false)
.Store(
Html.X().Store()
.ID("Store1")
.AutoLoad(false)
.Proxy(Html.X().AjaxProxy()
.Url(Url.Action("rowExpander"))
.Reader(Html.X().JsonReader().Root("data"))
)
.Model
(
Html.X().Model()
.Fields
(
Html.X().ModelField().Name("rowexpandertext").Type(ModelFieldType.String)
)
)
)
.ColumnModel
(
Html.X().Column()
.DataIndex("rowexpandertext")
.Text("rowexpandertext")
)
.SelectionModel
(
X.CheckboxSelectionModel()
.Mode(SelectionMode.Multi)
)
)
)
.TopBar
(
Html.X().Toolbar()
.Items
(
// Start of Item 3
Html.X().Button()
.ID("btnAdd")
.Text("Add record")
.Icon(Icon.Add)
.Handler("")
)
)
)
)
@(X.Button().Text("Click to open source grid window")
.Listeners(l =>
{
l.Click.Handler = "App.Window1.show()";
})
)
Example Controllerpublic class Copy_Grid_to_gridController : Controller
{
//
// GET: /Copy_Grid_to_grid/
public ActionResult Index()
{
var l = new List<testGrid>();
for (int i = 0; i <= 2; i++)
{
var o = new testGrid()
{
reqid = "GridPanel1-REQID-" + i.ToString(),
};
l.Add(o);
}
ViewBag.loadgrid = l;
return View();
}
public ActionResult grid2data()
{
var l2 = new List<testGrid>();
for (int i = 0; i <= 2; i++)
{
var o2 = new testGrid()
{
reqid = "GridPanel2-REQID-" + i.ToString(),
};
l2.Add(o2);
}
return this.Store(l2);
}
public ActionResult rowExpander(string reqid)
{
var l2 = new List<rowexpander>();
for (int i = 0; i <= 2; i++)
{
var o2 = new rowexpander()
{
rowexpandertext = "Rowexpander-"+reqid+"-" + i.ToString()
};
l2.Add(o2);
}
return this.Store(l2);
}
}
public class testGrid
{
public string reqid { get; set; }
}
public class rowexpander
{
public string rowexpandertext { get; set; }
}
Html.X().Button()
.ID("btnAdd")
.Text("Add record")
.Icon(Icon.Add)
.Handler("App.targetgrid.getStore().add(record); this.up('gridpanel').store.removeAt(recordIndex);")
)
but this not working .how I get regrid for remove record?
App.targetgrid.getStore().add(record);
A Button's Handler doesn't have such the parameter. It is just a shorthand of a Button's Click listener..SingleExpand(false)
.SingleExpand(true)
which may helpfull.SingleExpand(false)
because my users expand each section,select some rows/record from grid inside Rowexpander (here regrid) and finally click on "Add record" .