PDA

View Full Version : [CLOSED] Reload a grid store from a window - MVC



registrator
May 02, 2015, 1:08 PM
I have a grid with records and the edit of these records is in Window. On Save button click on the Window direct event I go back to the controller method to save the record and I have this in the controller method



var store = this.GetCmp<Store>("RecordsGridStore");
store.Reload();


The message that I get in the browser is: Cannot read property 'reload' of undefined

In this scenario above, how do you reload a grid store from MVC method?

Thank you

Daniil
May 04, 2015, 10:35 PM
Hi @registrator,


In this scenario above, how do you reload a grid store from MVC method?

A Store's .Reload() call is going to work if the Store has a remote proxy associated to it. Has it?


The message that I get in the browser is: Cannot read property 'reload' of undefined

Please provide a test case to reproduce.

registrator
May 05, 2015, 8:45 AM
Hi Daniil

this is the grid and store definition. I cannot get it to reload.



X.GridPanel()
.EnableColumnHide(false)
.ID("GridCustomers")
.Store(
X.Store()
.ID("SalesRecordsGridStore")
.Data(Model)
.AutoLoad(true)
.Proxy(
Html.X().AjaxProxy()
.Url(Url.Action("GetList", "List", new { area = "SalesRecord" }))
.Reader(Html.X().JsonReader().Root("data"))
)
.Model(
X.Model()
.Name("Invoce")
.IDProperty("ACCOUNT_REF")
.Fields(
X.ModelField()
.Name("NAME")
.Type(ModelFieldType.String),
X.ModelField()
.Name("ACCOUNT_REF")
.Type(ModelFieldType.String),
X.ModelField()
.Name("BALANCE")
.Type(ModelFieldType.Float),
X.ModelField()
.Name("CREDIT_LIMIT")
.Type(ModelFieldType.Float),
X.ModelField()
.Name("CONTACT_NAME")
.Type(ModelFieldType.String),
X.ModelField()
.Name("TELEPHONE")
.Type(ModelFieldType.String)
)
)
.Sorters(X.DataSorter().Property("NAME").Direction(Ext.Net.SortDirection.ASC))
.Listeners( l => {
l.Load.Handler = "sum(App.GridCustomers);";
})
)
.ColumnModel(X.Column().Text("A/C").DataIndex("ACCOUNT_REF").Flex(1),
X.Column().Text("Name").DataIndex("NAME").Renderer("companyNameColor").Flex(1),
X.NumberColumn().Text("Balance").DataIndex("BALANCE").Renderer("balanceColor").Align(Alignment.Right).Flex(1),
X.NumberColumn().Text("Credit Limit").DataIndex("CREDIT_LIMIT").Align(Alignment.Right).Flex(1),
X.Column().Text("Contact Name").DataIndex("CONTACT_NAME").Flex(1),
X.Column().Text("Telephone").DataIndex("TELEPHONE").Flex(1)
)
.SelectionModel(Html.X().RowSelectionModel().Mode( SelectionMode.Simple))
.Features(X.GridFilters()
.Local(true)
.ID("GridFilters1")
.Filters(
X.StringFilter().DataIndex("ACCOUNT_REF"),
X.StringFilter().DataIndex("NAME"),
X.NumericFilter().DataIndex("BALANCE"),
X.NumericFilter().DataIndex("CREDIT_LIMIT"),
X.StringFilter().DataIndex("CONTACT_NAME"),
X.StringFilter().DataIndex("TELEPHONE")
)
.Listeners(l => l.FilterUpdate.Handler = "sum(App.GridCustomers);")
)




var store = this.GetCmp<Store>("SalesRecordsGridStore");
store.Reload();

matrixwebtech
May 05, 2015, 9:41 AM
Hi
May be bellow code solve your problem

Set ServerProxy instead Proxy .

registrator
May 05, 2015, 10:21 AM
No, I get nothing in the grid if I do that.
Thnx

matrixwebtech
May 05, 2015, 10:38 AM
Hi
I think you you should remove .Data(Model) and load the grid with Serverproxy only.

registrator
May 05, 2015, 10:59 AM
there is nothing in the grid again if I do that

Daniil
May 05, 2015, 12:13 PM
@registrator, is that helpful?
http://forums.ext.net/showthread.php?36991&p=166961&viewfull=1#post166961

If the issue persists, please provide a full test case to reproduce.

registrator
May 05, 2015, 10:07 PM
This is an architecture issue. I will explain. Since my solution is based on your mvc examples solution, i have the edit form opening on top of the tabs and that is why the reload does not see the store.
I will need to change my edit window structure not to open it on top of tabs but inside.