PDA

View Full Version : form.updateRecord wont work



Richie1985
5 Apr 2013, 1:01 AM
hi,

i use this example: http://docs.sencha.com/ext-js/4-2/extjs-build/examples/charts/FormDashboard.html

i integrate a taskrunner to reload the store every 5 seconds. now my problem:

1. i select a record in the grid
2. the record is loading into the grid
3. i change something in the form and the store is updating with form.updateRecord(selectRecord)

Point 3 only works within the 5 seconds, after this 5 seconds form.updateRecord(selectRecord) do nothing. It seems the store is losing a focus or something else?

Can you help me?

thx!

slemmon
6 Apr 2013, 2:56 PM
Is selectRecord still a record instance at that point?

Richie1985
7 Apr 2013, 3:26 AM
how can i check this?

Richie1985
7 Apr 2013, 9:22 PM
i think yes, because the "updateRadarChart(selectedRec);" command works well...

slemmon
8 Apr 2013, 6:08 AM
You may have to check the assumptions of your code using console.log() along the way to see what's changed (if anything) that's no longer allowing your store to reload. Before each critical step you might log the elements being used in the function inside your task.

i.e. console.log(selectedRecord) prior to form.updateRecord(selectRecord)

Richie1985
9 Apr 2013, 2:13 AM
i tried this, and i cant find any differences betweens this console.log output before store.load and after.

slemmon
9 Apr 2013, 8:39 AM
You may need to console.log() the components involved before/after the timeout to see what is changing. You might also try setting breakpoints in the code to see if there is a different path taken before and after the timeout.

Richie1985
12 Apr 2013, 6:40 AM
sorry, i dont realy understand it. console.log(selectRec) logs everytime the same.

i use the example and only this i added:


var runner = new Ext.util.TaskRunner();

var task = runner.newTask({
run: function () {
ds.load()
},
interval: 5000
});
task.start();

after every reload of the store i have to select the record new.

slemmon
12 Apr 2013, 5:30 PM
I tried recreating the issue by editing the example myslef, but I'm still not seeing the issue you're describing (at least as I understand it). You may have to post a working example that demonstrates the issue you're seeing.

Richie1985
14 Apr 2013, 10:00 PM
after you add this taskrunner, please do this things:

1. Select a Row in the Grid
2. Change Values in the Formular, the big chart on the top will be changed and the grid values too
3. after this 5 Seconds you cant change values for the grid or the top chart, only the small chart under the form will be changed
4. you must reselect the row in the grid to change the values again


listeners: {
// buffer so we don't refire while the user is still typing
buffer: 200,
change: function(field, newValue, oldValue, listener) {
if (selectedRec && form) {
if (newValue > field.maxValue) {
field.setValue(field.maxValue);
} else {
if (form.isValid()) {
form.updateRecord(selectedRec); <-- this is not working
updateRadarChart(selectedRec); <-- this is working
}
}
}
}
}

slemmon
15 Apr 2013, 12:23 PM
I see.
After the grid's store is updated the record you have loaded to the form (which owns the radar chart) no longer exists in the store used by the grid and column chart. To update those on a form edit you'll need to find the record in the store matching the one up just updated and update it as well.

Try with this:


listeners: {
// buffer so we don't refire while the user is still typing
buffer: 200,
change: function(field, newValue, oldValue, listener) {
if (selectedRec && form) {
if (newValue > field.maxValue) {
field.setValue(field.maxValue);
} else {
if (form.isValid()) {
form.updateRecord(selectedRec);
updateRadarChart(selectedRec);
var index = ds.find('company', selectedRec.get('company'));
var values = form.getValues();
ds.getAt(index).set(values);
}
}
}
}
}

Richie1985
15 Apr 2013, 10:33 PM
thank you thank you thank you thank you thank you thank you thank you thank you

that works realy cool!