jQWidgets Forums
jQuery UI Widgets › Forums › Plugins › Data Adapter › Optional data field's mapping
This topic contains 15 replies, has 5 voices, and was last updated by fjean 10 years, 6 months ago.
-
Author
-
We found a similar problem which seem to be working fine with when using json a data but is not working when using observablearray for aour data source.
First case , mapping comment text when comment isnt defined at all in data source, working as intended :
http://jsfiddle.net/sGGZ3/164/Code :
var data = ko.observableArray( [
{ id: 100} ,
{ id: 101 , comment : {text : “toto” }},
{ id: 102 }
]);
// prepare the data
var source =
{
datatype: “observablearray”,
datafields: [
{ name: ‘id’, type: ‘number’},
{ name: ‘commenttext’ , map : ‘comment>text’}
],
localdata: data
};
var dataAdapter = new $.jqx.dataAdapter(source);
$(“#jqxgrid”).jqxGrid(
{
width: 300,
source: dataAdapter,
columns: [
{ text: ‘Id’, datafield: ‘id’ },
{ text: ‘Comment’, datafield: ‘commenttext’ }
]
});——————————————————————————————————————-
Second case mapping comment text when comment is set to null in datasource :
http://jsfiddle.net/sGGZ3/165/var data = ko.observableArray( [
{ id: 100 , comment : null} ,
{ id: 101 , comment : {text : “toto” }},
{ id: 102 }
]);
// prepare the data
var source =
{
datatype: “observablearray”,
datafields: [
{ name: ‘id’, type: ‘number’},
{ name: ‘commenttext’ , map : ‘comment>text’}
],
localdata: data
};
var dataAdapter = new $.jqx.dataAdapter(source);
$(“#jqxgrid”).jqxGrid(
{
width: 300,
source: dataAdapter,
columns: [
{ text: ‘Id’, datafield: ‘id’ },
{ text: ‘Comment’, datafield: ‘commenttext’ }
]
});Getting error : Uncaught TypeError: Cannot read property ‘text’ of null. I think it is a bug because the behavior of mapping is not constant between datasource datatype (json vs observablearray) and the fact that an undefined comment (which work) conceptually is the same as setting comment : null
-
AuthorPosts
You must be logged in to reply to this topic.