PDA

View Full Version : Combobox items not showing in IE



lindasingini
11 May 2011, 4:21 AM
Hi All, i have a combobox which am populating using a json store as normal. When i click the arrow to see the items in Firefox they show with no problem but in IE they are not visible.Please help.Thank you.

fay
11 May 2011, 6:23 AM
Can't really help without seeing your code and json response, but most likely you've a trailing comma somewhere - this tends to be the most common issue with "works in FF, but not in IE..."

Have you validated your JS with www.jslint.com (http://www.jslint.com) and your JSON with www.jsonlint.com (http://www.jsonlint.com)?

lindasingini
11 May 2011, 10:29 PM
Here is my code below. The same code actually works in IE 8 but not in IE 9 ???:((

var contractedTypeRecordFields = ['ContractTypeID', 'ContractTypeName'];
var jsonDataStoreForContractedType = new Ext.data.JsonStore({
fields: contractedTypeRecordFields,
url: 'Services/Misc.aspx?action=readcontracttypes',
root: 'rows',
autoLoad: true
});

var comboBoxForContractedTypes = new Ext.form.ComboBox({
store: jsonDataStoreForContractedType,
displayField: 'ContractTypeName',
valueField: 'ContractTypeID',
hiddenName: 'ContractTypeID',
fieldLabel: 'Contract Type',
mode: 'local',
triggerAction: 'all',
width: 210

});

//////////////To get the data from DB//////////////////

protected void Page_Load(object sender, EventArgs e)
{
switch (Request.Params["action"])
{
case "readcontracttypes":
ReadContractTypes();
break;
default:
break;
}
}


private void ReadContractTypes()
{
var contractTypes = from ct in db.ContractTypes
select new { ct.ContractTypeID, ct.ContractTypeName };
json = serializer.Serialize(contractTypes);
Response.Write("{rows: " + json + "}");
}

shuixiya1999
12 May 2011, 12:18 AM
It's a comma problem.

Your json has a comma more in the end.

My English is not good,can u understand?

lindasingini
12 May 2011, 12:40 AM
This is the resultant string for my json.Please may you point out my error.I used www.jsonlint.com (http://www.jsonlint.com/) like fay said and got this error. Thanks fay for the sites.
"syntax error, unexpected TINVALID, expecting TSTRING or '}' at line 2 Parsing failed"


Am not sure where am going wrong.

{
rows: [
{
"ContractTypeID": 1,
"ContractTypeName": "Delivered"
},
{
"ContractTypeID": 2,
"ContractTypeName": "FOT"
}
]
}

fay
12 May 2011, 1:26 AM
Your JSON is fine; if you double-quote "rows" you'll get no errors - this is just something jsonlint requires, but Ext JS doesn't.

I don't have IE9 on this PC so can't test the following, but I'd suggest you try it - it might help determine whether its the json, your combo def, or something else in your code that causes IE9 issues:

getjson.php



<?php
$buff = '{
rows: [
{
"ContractTypeID": 1,
"ContractTypeName": "Delivered"
},
{
"ContractTypeID": 2,
"ContractTypeName": "FOT"
}
]
}';
header('Content-Type: application/json');
echo $buff;
?>


test.html



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>

<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all-debug.js"></script>

<script>
Ext.onReady(function(){
var contractedTypeRecordFields = ['ContractTypeID', 'ContractTypeName'];

var jsonDataStoreForContractedType = new Ext.data.JsonStore({
fields: contractedTypeRecordFields,
url: 'getjson.php',
root: 'rows',
autoLoad: true
});

var comboBoxForContractedTypes = new Ext.form.ComboBox({
store: jsonDataStoreForContractedType,
displayField: 'ContractTypeName',
valueField: 'ContractTypeID',
hiddenName: 'ContractTypeID',
fieldLabel: 'Contract Type',
mode: 'local',
triggerAction: 'all',
width: 210,
applyTo: 'test-combo'
});
});
</script>

</head>
<body>
<div>
<input type="text" id="test-combo" size="20"/>
</div>
</body>
</html>