Reputation: 3
I'm new in ExtJs and i'm stuck with some problems. This is my model:
Ext.define('MyTestApp.model.Product', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'},
{name: 'name', type: 'string'},
{name: 'description', type: 'string'},
{name: 'price', type: 'float'},
{name: 'count', type: 'int'}
],});
This is store:
Ext.define('MyTestApp.store.Products', {
extend: 'Ext.data.Store',
alias: 'store.products',
storeId: 'products',
model: 'MyTestApp.model.Product',
data: [
{id: 1, name: 'Notebook Lenovo', description: 'Ноутбук Lenovo IdeaPad 330-15IKB', price: 100, count: 2},
{id: 2, name: 'Logitech Keyboard', description: 'Клавиатура Logitech Comfort K280E', price: 50, count: 9},
{id: 3, name: 'Logitech Mouse', description: 'Мышь Logitech M90', price: 25, count: 0},
{id: 4, name: 'Gaming mouse pad', description: 'Коврик для мыши A4Tech X7-200MP', price: 150, count: 5},
{id: 5, name: 'Samsung smartphone', description: 'Смартфон Samsung Galaxy A51 64GB', price: 122, count: 3},
{id: 6, name: 'Protective glass', description: 'Защитное стекло Samsung InterStep FSC', price: 10, count: 33},
],});
I want to add/update some records in the store, but methods such as store.load() or newModelInstance.save() doesn't work. Error in console: POST http://localhost:1841/MyTestApp.model.Product?_dc=1596285700466 404 (Not Found)
Upvotes: 0
Views: 165
Reputation: 4706
To add new record into store you can use store.add({id:123, name: “some name”...}) method. To update records, something like strore.findRecord() and then update the found record in the store i.e. record.set(fieldName, fieldValue). To update the store/records data on the server (commit), you must configure proxy for store/record.
Upvotes: 0