によって変更されたオブジェクトをレンダリングしていない私のコードです:JSON.stringify()ここでイベント
//column reorder event
dataTable.on('column-reorder', function (e, settings, details) {
var userData = tableWidget.grid('userData');
console.log(userData); //the object which is correct already
console.log(JSON.stringify(userData)); //somehow it's different than without stringify
$.ajax({
url: "../../server/post.aspx?tableEvent=reordercolumns&table=SubContractor",
data: { dataColumnOrder: userData },
dataType: "json",
type: "POST",
success: function (response) {
//write JS when ajax call success
console.log('success');
},
error: function() {
console.log("Something wrong with the columns' reorder saving process");
}
});
console.log("Reordered");
});
このイベントはuserData
オブジェクトを更新します。更新部分は正常に動作します。残念ながら、私はそれを文字列化すると、userData
オブジェクトがデフォルト値に戻ります。文字列化console.log(JSON.stringify(userData));
で
:文字列化console.log(userData);
、(正しい)がなければ
:ここに私はそれのスクリーンショットを添付
{
"view": "SubContractorGridView",
"title": "SubContractor Grid View",
"settings": {
"colOrder": ["Id", "ExtKey", "InsertionDate", "DeletionDate", "Name", "Address", "ZipCode", "EmailAddress", "PhoneNumber", "UserName", "Password", "LastUpdate", "Price"],
"orderBy": "Name",
"orderDir": "asc"
},
"columns": [{
"dbField": "Id",
"show": true,
"widthMobile": 90,
"widthPhablet": 89,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 90,
"widthDesktop": 90,
"widthLargeDesktop": 90
}, {
"dbField": "ExtKey",
"show": false,
"widthMobile": 90,
"widthPhablet": 120,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 150,
"widthDesktop": 90,
"widthLargeDesktop": 100
}, {
"dbField": "InsertionDate",
"show": true,
"widthMobile": 90,
"widthPhablet": 100,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 100,
"widthDesktop": 90,
"widthLargeDesktop": 110
}, {
"dbField": "DeletionDate",
"show": false,
"widthMobile": 90,
"widthPhablet": 90,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 90,
"widthDesktop": 90,
"widthLargeDesktop": 100
}, {
"dbField": "Name",
"show": true,
"widthMobile": 90,
"widthPhablet": 130,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 90,
"widthDesktop": 90,
"widthLargeDesktop": 90
}, {
"dbField": "Address",
"show": true,
"widthMobile": 90,
"widthPhablet": 90,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 90,
"widthDesktop": 90,
"widthLargeDesktop": 90
}, {
"dbField": "ZipCode",
"show": true,
"widthMobile": 90,
"widthPhablet": 90,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 90,
"widthDesktop": 90,
"widthLargeDesktop": 90
}, {
"dbField": "EmailAddress",
"show": true,
"widthMobile": 90,
"widthPhablet": 90,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 90,
"widthDesktop": 90,
"widthLargeDesktop": 90
}, {
"dbField": "PhoneNumber",
"show": true,
"widthMobile": 90,
"widthPhablet": 90,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 90,
"widthDesktop": 90,
"widthLargeDesktop": 90
}, {
"dbField": "UserName",
"show": true,
"widthMobile": 90,
"widthPhablet": 90,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 90,
"widthDesktop": 90,
"widthLargeDesktop": 90
}, {
"dbField": "Password",
"show": true,
"widthMobile": 90,
"widthPhablet": 90,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 90,
"widthDesktop": 90,
"widthLargeDesktop": 90
}, {
"dbField": "LastUpdate",
"show": true,
"widthMobile": 90,
"widthPhablet": 90,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 90,
"widthDesktop": 90,
"widthLargeDesktop": 90
}, {
"dbField": "Price",
"show": true,
"widthMobile": 90,
"widthPhablet": 90,
"widthMiniTablet": 90,
"widthTablet": 90,
"widthSmallDesktop": 90,
"widthDesktop": 90,
"widthLargeDesktop": 90
}
]
}
あなたは、列の順序を何とか見ることができるようにstringifyでデフォルトのものに戻ります。
について
console.clear()
より高齢の値に興味を持っていない場合は、コンソールをきれいにすることも可能です。 –成功コールバックはどうなりますか? – Scimonster