May 09, 2013, 12:15 PM
[CLOSED] performing editing the grid inside row expander plugin
I have a problem editing and saving the data of grid panel inside the row expander plugin.
I have used a row expander plugin which reside a form panel and a grid showing various data. I need to save the changes made in the grid panel but i have difficulty passing the changed data to the controller i have created.
the code for row expander
when the row is expanded proxy is called to build the grid panel
When i click save it need to save the changes made in the form panel as well as grid panel and the row is collapsed
This button calls the controller to save data to database
the controller
I have used a row expander plugin which reside a form panel and a grid showing various data. I need to save the changes made in the grid panel but i have difficulty passing the changed data to the controller i have created.
the code for row expander
Plugins(Html.X().RowExpander()
.ID("ratingRowExpander")
.SingleExpand(false)
.Component(
Html.X().FormPanel()
.ID("RatingScaleMainForm")
.Icon(Icon.User)
.Frame(true)
.BodyPadding(10)
.Items(
Html.X().Container()
.Layout(LayoutType.HBox)
.MarginSpec("0 0 10")
.Items(Html.X().FieldSet().Flex(1).Title("FormPanel").Layout(LayoutType.Anchor).DefaultAnchor("100%")
.Items(
Html.X().TextField().Name("Id").FieldLabel("Id").ReadOnly(true),
Html.X().TextField().FieldLabel(Title")).Name("Title"),
Html.X().FieldSet().Title("grid panel").Layout(LayoutType.Fit).Height(300).DefaultAnchor("100%").AutoScroll(true)
.Items(
Html.X().GridPanel()
.ID("gridResult1")
.Border(true)
.Height(300)
.AutoScroll(true)
.Store(Html.X().Store()
.ID("ratingScaleDefinitionStore")
.Proxy(Html.X().AjaxProxy()
.Url(Url.Action("GetGridpanelData, "AcData"))
.Reader(Html.X().JsonReader().Root("data"))
)
.Parameters(parameterStore => {
parameterStore.Add(Html.X().StoreParameter().Name("Id").Mode(ParameterMode.Value).Value("Ext.getCmp('gridResult').getSelectionModel().getSelection()[0].data.Id"));
})
.RemoteSort(true)
.RemotePaging(true)
.Model(Html.X().Model().IDProperty("id").Name("grid")
.Fields(
new ModelField("name", ModelFieldType.String),
new ModelField("Title", ModelFieldType.String),
)
))
.ColumnModel(
Html.X().CommandColumn().Width(30).Flex(1).Draggable(false).Commands(Html.X().GridCommand().CommandName("deleteRow").Icon(Icon.BulletMinus).StandOut(true)).Listeners(l => l.Command.Handler = "deleteRow();"),
Html.X().Column().Text("Name").DataIndex("name").Flex(2).Editor(Html.X().TextField().AllowBlank(false)),
Html.X().Column().Text("Title").DataIndex("Title").Flex(3).Editor(Html.X().TextField().AllowBlank(false)),
Html.X().Column().Text(Compensation.UI.Controllers.Base.BaseController.GetLabelText("LBL_DESCRIPTION_TEXT")).DataIndex("Description").Flex(4).Editor(Html.X().TextField().AllowBlank(false))
).Plugins(Html.X().CellEditing())
)
)
.Buttons(
Html.X().Button().Text("Save").Icon(Icon.DatabaseSave).Handler(@"var grid = this.up('grid'), form = this.up('form');
grid.getRowExpander().collapseRow(grid.store.indexOf(form.record)); form.getForm().updateRecord(form.record);
Ext.getCmp('gridResult').getRowExpander().componentsCache[0].cmp.items.items[1].items.items[0].store.save();"),
Html.X().Button().Text("Cancel").Icon(Icon.Cancel).Handler(@"var grid = this.up('grid'), form = this.up('form');
grid.getRowExpander().collapseRow(grid.store.indexOf(form.record));")
)
.Listeners(l => { l.AfterRender.Handler = "this.getForm().loadRecord(this.record);"; })
when the row is expanded proxy is called to build the grid panel
When i click save it need to save the changes made in the form panel as well as grid panel and the row is collapsed
This button calls the controller to save data to database
Html.X().Button().Icon(Icon.Disk).Disabled(!canSave).DirectEvents(de =>
{
de.Click.Url = Url.Action("SaveData", "AcData");
de.Click.ExtraParams.Add(new Parameter("data", "#{ratingScaleStore}.getChangedData({skipIdForNewRecords : false})", ParameterMode.Raw, true));
de.Click.ExtraParams.Add(new Parameter("data1", "Ext.getCmp('gridResult').getRowExpander().componentsCache[0].cmp.items.items[1].items.items[0].store.getUpdatedRecords()", ParameterMode.Raw, true));
de.Click.Success = "SaveDataSuccess(response,result,this,type,action,#{ratingScaleStore});";
}).Text("save all data")
);
the controller
public virtual ActionResult SaveData(string data,string data1)
{
try
{
///no data
//perform task
}
Last edited by Daniil; May 16, 2013 at 3:40 AM.
Reason: [CLOSED]