PDA

View Full Version : How to send to the server the date value as param in baseParams?



beyonlo
22 Apr 2012, 5:49 PM
I`m have a simple app and trying to send to the server the date value via baseParams

I`m have a "get images" icon on toolbar and when I click on it, the store is loaded. Are there a function in baseParams to get the new value of date component inside toolbar. Problem that is not working. I did a test using a default value in start app with  "value: new Date()," and works, but just with always the same default value. If I change the date to any value and click in "Get images" again, the date value that is sent to server is the always the same when started with "value: new Date()"

What extjs sent to the server when "value: new Date()," is used:
{'_dc': u'1335142100280', 'task': u'2012-04-22T21:48:14'} -> ALWAYS SAME VALUE

What extjs sent to the server when "value: new Date()," is not used:
{'_dc': u'1335142797421', 'task': u''} -> HERE IS WHERE I WANT TO SEND THE DATE

I`m using Ext JS 3.4

Any idea?

Thanks,

Code:



Ext.onReady(function(){
var tbar = new Ext.Toolbar({
style: 'border:1px solid #99BBE8;'
});

tbar.add({
text: 'Get Images',
icon: 'img/delete.png',
handler: function() { store.load() }
}, '->',{
fieldLabel: 'Date from',
name: 'datefrom',
id: 'datefrom',
xtype:'datefield',
//value: new Date(),
format:'d/m/Y'
});


function update_image()
{
date_start = Ext.getCmp('datefrom').getValue()
return date_start
}


var store = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: 'get_images_playback_view', method: 'GET'
}),
baseParams:{task: update_image() },
root: 'images',
fields: [
'name', 'url', 'size', 'lastmod', 'thumb_url', 'shortName', 'id'
]
});




var panelLeft = new Ext.Panel({
id: 'images-view',
frame: true,
collapsed : false,
collapsible : true,
width: 640,
height: 200,
autoHeight: true,
layout: 'auto',
title: 'ExtJS DataView With Pagination',
items: [tbar]
});
panelLeft.render('left');


});

scottmartin
22 Apr 2012, 8:58 PM
You need to refresh the baseParams for each call. You are setting when you define the store.



store.baseParams = {}; // clear any previous params
store.baseParams = { task: update_image() }
store.load();


Regards,
Scott.

beyonlo
23 Apr 2012, 4:03 AM
Works.

Thank you!