PDA

View Full Version : CoboBox fill Using JsonReader not working for me --Help



sam.arulprakash
14 Jun 2010, 1:22 AM
Hi all,

The below code not working as expected.(It is not fill the combo.)
Please help me.

Thanks in advance.

Regards,
Arul Prakash.M

(sorry for title-its Combo not Cobo)


ComboBox2_ds = new Ext.data.Store
({
proxy: new Ext.data.HttpProxy
({
url:*****/FillComboDataset",
method: "POST",
nocache: true
}),
reader: new Ext.data.JsonReader
({
fields:['NAME','IMO_NR'],
root:'root'
}),
autoLoad: true
});



ComboBox2 = new Ext.form.ComboBox({
store: ComboBox2_ds,
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
emptyText:'- Select a value -',
selectOnFocus:true,
autocomplete:true,
mode:'local',
displayField: 'NAME',
applyTo: 'ComboBoxText',

valueField: 'IMO_NR',
TextValue:function()
{
return this.getStore().getAt(this.selectedIndex).data.IMO_NR;
},

Text:function()
{return this.getValue();},
SetText:function(obj)
{return this.setValue(obj);},
ValidationError:function()
{

}
});

JSON STRING='[ root:{"Name":"L1001702 ","IMO_NR":"FLEURTJE"},.....................'

Condor
14 Jun 2010, 1:40 AM
1. You can't do a POST when you have no parameters.
2. Is your URL on the same domain?

sam.arulprakash
14 Jun 2010, 1:49 AM
Thanks Condor for your reply.

For the 2nd question,
Yes.
For the 1st question,
I have changed method: "GET", but also not working.

Thanks and Regards,
Arul Prakash.M

Condor
14 Jun 2010, 1:57 AM
Your JSON string is invalid.

It should be:

{root:[{"NAME":"L1001702 ","IMO_NR":"FLEURTJE"},.....................]}

sam.arulprakash
14 Jun 2010, 2:23 AM
I am getting this Json string,After made your change.
but still i am not able to make it.

Thanks Condor.


{ root:[{"NAME":"L1001702 ","IMO_NR":"FLEURTJE"},{"NAME":"L8817722 ","IMO_NR":"ARCO BECK"},{"NAME":"L4902945 ","IMO_NR":"OILSTONE"},{"NAME":"L4906410 ","IMO_NR":"OILFIELD"},{"NAME":"L5000172 ","IMO_NR":"ALLEGRO"},{"NAME":"L5000201 ","IMO_NR":"TUNC"},{"NAME":"L5000342 ","IMO_NR":"AL-MARKHANIYA"},{"NAME":"L5000562 ","IMO_NR":"TELANBO"},{"NAME":"L5000782 ","IMO_NR":"LE TRIEUX"},{"NAME":"L5000835 ","IMO_NR":"HIOS"}]}

Condor
14 Jun 2010, 3:12 AM
It's time to debug.

- Is the request made and is the response correct?
- Does the store fire a 'load' or an 'exception' event?

sam.arulprakash
14 Jun 2010, 4:52 AM
1st Point.
If i gave method:'Post' then only the request reach to my web service and i am able to debug it.
But in 'GET' I am not able to debug.(I think the request not send to service.)
2nd point
Load event alone firing.
I have tried to fire 'exception' event (By changing URL) ,But it is not firing.

And there is no javascript error in IE.


Thanks Condor.

Still the problem exists......




<script language="javascript" type="text/javascript">
var cbReportType;
var cbReportType_ds;
var cbReportType_ArrayStore;
Ext.onReady(function()
{
Ext.QuickTips.init();


cbReportType_ds = new Ext.data.Store
({
proxy: new Ext.data.HttpProxy
({
url: "http://localhost/Test.asmx/FillComboDataset",
method: "POST",
nocache: true

}),
reader: new Ext.data.JsonReader
({
fields:['shipName','shipIMONo'],
root:'root'
}),
autoLoad: true,
load:function()
{
alert('1');
},
exception:function()
{
alert('2');
},
loadexception:function()
{
alert('3');
}
});



cbReportType = new Ext.form.ComboBox({
store: cbReportType_ds,
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
emptyText:'- Select a value -',
selectOnFocus:true,
autocomplete:true,
mode:'local',
displayField: 'shipName',
applyTo: 'cbReportType_Text',

valueField: 'shipIMONo',
TextValue:function()
{
return this.getStore().getAt(this.selectedIndex).data.shipIMONo;
},

Text:function()
{return this.getValue();},
SetText:function(obj)
{return this.setValue(obj);},
ValidationError:function()
{

}
});





});
</script>


My Json String

{ root:[{"ShipName":"L1001702 ","ImoNumber":"FLEURTJE"},{"ShipName":"L8817722 ","ImoNumber":"ARCO BECK"},{"ShipName":"L4902945 ","ImoNumber":"OILSTONE"},{"ShipName":"L4906410 ","ImoNumber":"OILFIELD"},{"ShipName":"L5000172 ","ImoNumber":"ALLEGRO"},{"ShipName":"L5000201 ","ImoNumber":"TUNC"},{"ShipName":"L5000342 ","ImoNumber":"AL-MARKHANIYA"},{"ShipName":"L5000562 ","ImoNumber":"TELANBO"},{"ShipName":"L5000782 ","ImoNumber":"LE TRIEUX"},{"ShipName":"L5000835 ","ImoNumber":"HIOS"}]}</

Condor
14 Jun 2010, 10:06 PM
var cbReportType;
var cbReportType_ds;
var cbReportType_ArrayStore;
Ext.onReady(function () {
Ext.QuickTips.init();
cbReportType_ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: "/Test.asmx/FillComboDataset", // <- don't specify domain
method: "POST",
disableCaching: true
}),
reader: new Ext.data.JsonReader({
fields: ['shipName', 'shipIMONo'],
root: 'root'
}),
autoLoad: {
params: {
'some-param': 'some-value' // <- POST can only work if you have at least one parameter
}
},
listeners: { // <- load, loadexception and exception are events
load: function () {
alert('1');
},
exception: function () {
alert('2');
},
loadexception: function () {
alert('3');
}
}
});
cbReportType = new Ext.form.ComboBox({
store: cbReportType_ds,
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
emptyText: '- Select a value -',
selectOnFocus: true,
//autocomplete: true,
mode: 'local',
displayField: 'shipName',
applyTo: 'cbReportType_Text',
valueField: 'shipIMONo',
hiddenName: 'shipIMONo',
TextValue: function () {
return this.getValue();
},
Text: function () {
return this.getRawValue();
},
SetTextValue: function (obj) {
return this.setValue(obj);
},
ValidationError: function () {

}
});
});

sam.arulprakash
14 Jun 2010, 11:48 PM
Thank u very much condor.

I am getting type->Response.action->Read
from exception event.





exception:function(proxy, type, action)
{
alert(type +' ' + action + ' '+proxy+ ' exception');
}

Condor
15 Jun 2010, 1:46 AM
I'm more interrested in the error and the response:

exception: function(proxy, type, action, options, response, e){
alert('type: ' + type + '\naction: ' + action + '\nerror: ' + e + '\nresponse: ' + response.responseText);
}

sam.arulprakash
15 Jun 2010, 2:06 AM
Once again,Thanks Condor.
I am getting type->Response,
action->Read,
error->undefined,
response->System.InvalidOperationException:Request fromat is invalid:at System.Web.Services.Protocols.HttpServerProtocal.ReadParameters() at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
from exception event.

Condor
15 Jun 2010, 2:38 AM
So, it's a server problem! Your server is responding with:

System.InvalidOperationException:Request fromat is invalid
at System.Web.Services.Protocols.HttpServerProtocal.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

sam.arulprakash
20 Jun 2010, 11:16 PM
Hi Condor,

I have tried with XMLReader.
This time i come with "TypeError 'Prototype' is null or not an object''.
Response:My Xml String.

Any idea or suggestion about this error.

Thanks & Regards,
Arul Prakash.M


var cbReportType;
var cbReportType_ds;
var cbReportType_ArrayStore;
Ext.onReady(function()
{
Ext.QuickTips.init();

cbReportType_ds = new Ext.data.Store
({
proxy: new Ext.data.HttpProxy
({
url: "Test.asmx/Test",
method: "POST",
disableCaching: true
}),
reader: new Ext.data.XmlReader
({
record: 'Test',
id: 'SHPIMO_NR',
totalRecords: 'totalRecords'
}),
autoLoad: {
params: {
'some-param': 'some-value' // <- POST can only work if you have at least one parameter
}
},
listeners:
{
load:function()
{
},
exception: function(proxy, type, action, options, response, e)
{
alert('type: ' + type + '\naction: ' + action + '\nerror: ' + e + '\nresponse: ' + response.responseText);
},
loadexception:function(obj)
{
}
}
});


cbReportType = new Ext.form.ComboBox({
store: cbReportType_ds,
//typeAhead: true,
forceSelection: true,
triggerAction: 'all',
emptyText:'- Select a value -',
//selectOnFocus:true,
mode:'local',
displayField: 'SHPNAME',
applyTo: 'cbReportType_PhrsComboBoxText',
hiddenName: 'SHPIMO_NR',
valueField: 'SHPIMO_NR',
TextValue:function()
{
//return this.getStore().getAt(this.selectedIndex).data.shipIMONo;
return this.getValue();
},

Text:function()
{return this.getRawValue();},//return this.getValue();},
SetText:function(obj)
{return this.setValue(obj);},
ValidationError:function()
{

}
});











});