S
Shira Taytelbaom
Guest
Hi, I do it in JSON, But I don't know what's wrong... I copied here the index of the page that I ork on, (it's quite long), But I guess the important part is in "onShow" function that is written by the end- there I added the code you sent me! But I added the all page- because maybe you'll be able to see what's wrong, maybe according to all the definitions in the begininng.... Thanks a lot!!!!!! Here is the index page: 'use strict'; app.allWorkPlans = kendo.observable({ onShow: function () { }, afterShow: function () { }, isUpdated: false, showEditDelete: true, }); var aarr = {}; var aarr1 = {}; var aarr2 = {}; var aarr3 = {}; var aarr4 = {}; var aarr5 = {}; //var data1; //var data2; (function (parent) { var subject = {}; var status = {}; var object, a; var id, uid; var dataProvider = app.data.progressDataProvider, fetchFilteredData = function (paramFilter, searchFilter) { var model = parent.get('homeModel'), dataSource = model.get('dataSource'); //dataSource1 = model.get('dataSource1'); if (paramFilter) { model.set('paramFilter', paramFilter); } else { model.set('paramFilter', undefined); } if (paramFilter && searchFilter) { dataSource.filter({ logic: 'and', filters: [paramFilter, searchFilter] }); } else if (paramFilter || searchFilter) { dataSource.filter(paramFilter || searchFilter); } else { dataSource.filter({}); } //maybe here i can try to add more data sources //dataSource = model.get('dataSource1'); ////dataSource1 = model.get('dataSource1'); //if (paramFilter) { // model.set('paramFilter', paramFilter); //} else { // model.set('paramFilter', undefined); //} //if (paramFilter && searchFilter) { // dataSource.filter({ // logic: 'and', // filters: [paramFilter, searchFilter] // }); //} else if (paramFilter || searchFilter) { // dataSource.filter(paramFilter || searchFilter); //} else { // dataSource.filter({}); //} }, processImage = function (img) { if (!img) { var empty1x1png = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQI12NgYAAAAAMAASDVlMcAAAAASUVORK5CYII='; img = 'data:image/png;base64,' + empty1x1png; } return img; }, jsdoOptions = { name: 'kabat_training_task', autoFill: false }, jsdoOptions1 = { name: 'kabat_school_Guidelines_task', autoFill: false }, jsdoOptions2 = { name: 'Emergency_Drill', autoFill: false }, jsdoOptions3 = { name: 'kabat_kindergarden_training_task', autoFill: false }, jsdoOptions4 = { name: 'kabat_kindergarten_Guidelines_task', autoFill: false }, jsdoOptions5 = { name: 'kindergarden_Emergency_Drill', autoFill: false }, dataSourceOptions = { type: 'jsdo', transport: {}, schema: { model: { fields: { 'dueDate': { field: 'dueDate', defaultValue: '' }, } } }, serverFiltering: true, serverSorting: true, serverPaging: true, pageSize: 50 }, dataSourceOptions1 = { type: 'jsdo', transport: {}, schema: { model: { fields: { 'dueDate': { field: 'dueDate', defaultValue: '' }, } } }, serverFiltering: true, serverSorting: true, serverPaging: true, pageSize: 50 }, dataSourceOptions2 = { type: 'jsdo', transport: {}, schema: { model: { fields: { 'subject': { field: 'subject', defaultValue: '' }, } } }, serverFiltering: true, serverSorting: true, serverPaging: true, pageSize: 50 }, dataSourceOptions3 = { type: 'jsdo', transport: {}, schema: { model: { fields: { 'subject': { field: 'subject', defaultValue: '' }, } } }, serverFiltering: true, serverSorting: true, serverPaging: true, pageSize: 50 }, dataSourceOptions4 = { type: 'jsdo', transport: {}, schema: { model: { fields: { 'subject': { field: 'subject', defaultValue: '' }, } } }, serverFiltering: true, serverSorting: true, serverPaging: true, pageSize: 50 }, dataSourceOptions5 = { type: 'jsdo', transport: {}, schema: { model: { fields: { 'subject': { field: 'subject', defaultValue: '' }, } } }, serverFiltering: true, serverSorting: true, serverPaging: true, pageSize: 50 }, dataSource = new kendo.data.DataSource({ // data: [ ////{ name: "Xyz", dueDate: '04/04/1990' }, ////{ name: "Jane Doe", dueDate: '04/27/1988' }, // ], // sort: { field: "dueDate", dir: "asc" }, //Apply sorting by dob field // schema: { // model: { // fields: { // dueDate: { type: 'date' }, //Make sure you define a build with correct data type // name: { type: 'string' } // } // } // } pageSize: 50 }), //try to merge dataSources dataSource1 = new kendo.data.DataSource({ pageSize: 50 }), // data1 = dataSource.data(); //First data source data ////alert(data1 + "data1") //var data2 = dataSource1.data(); //Second data source data ////alert(data2 + "data2") ////concat two array data by converting kendo model to actual json //var mergedData = data1.toJSON().concat(data2.toJSON()); //alert(mergedData + "mergedData") //var newDataSource = new kendo.data.DataSource({ // data: mergedData, // sort: { field: 'dueDate', dir: 'asc' }, // schema: { // model: { // fields: { // dueDate: { type: 'date' }, // name: { type: 'string' }, // } // } // } //}); //alert(newDataSource + "newDataSource") //newDataSource.fetch(function () { // alert(newDataSource.total() + "newDataSource.total()"); // var data = newDataSource.view(); // console.log(data[0].dueDate); //}); dataSource2 = new kendo.data.DataSource({ pageSize: 50 }), dataSource3 = new kendo.data.DataSource({ pageSize: 50 }), dataSource4 = new kendo.data.DataSource({ pageSize: 50 }), dataSource5 = new kendo.data.DataSource({ pageSize: 50 }), dataSource10 = new kendo.data.DataSource({ pageSize: 50 }), homeModel = kendo.observable({ addRecord: null, dataSource: dataSource, dataSource1: dataSource1, dataSource2: dataSource2, dataSource3: dataSource3, dataSource4: dataSource4, dataSource5: dataSource5, dataSource10:dataSource10, _dataSourceOptions: dataSourceOptions, _dataSourceOptions1: dataSourceOptions1, _dataSourceOptions2: dataSourceOptions2, _dataSourceOptions3: dataSourceOptions3, _dataSourceOptions4: dataSourceOptions4, _dataSourceOptions5: dataSourceOptions5, _jsdoOptions: jsdoOptions, _jsdoOptions1: jsdoOptions1, _jsdoOptions2: jsdoOptions2, _jsdoOptions3: jsdoOptions3, _jsdoOptions4: jsdoOptions4, _jsdoOptions5: jsdoOptions5, searchChange: function (e) { var searchVal = e.target.value, searchFilter; if (searchVal) { searchFilter = { //here you decide according to what it'll be filtering- according to 'name' 'subject'.... field: 'name', operator: 'contains', value: searchVal }; } fetchFilteredData(homeModel.get('paramFilter'), searchFilter); }, currentItem: null, itemClick: function (e) { var dataItem = e.dataItem || homeModel.originalItem; //alert(e.dataItem.uid) app.mobileApp.navigate('#components/worksPlans1/trainingTaskSchoolDetails.html?uid=' + e.dataItem.uid); }, itemClick1: function (e) { var dataItem = e.dataItem || homeModel.originalItem; app.mobileApp.navigate('#components/worksPlans1/directiveTaskSchoolDetails.html?uid=' + e.dataItem.uid); }, itemClick2: function (e) { var dataItem = e.dataItem || homeModel.originalItem; //alert(e.dataItem.uid) app.mobileApp.navigate('#components/worksPlans1/exerciseTaskSchoolDetails.html?uid=' + e.dataItem.uid); }, itemClick3: function (e) { var dataItem = e.dataItem || homeModel.originalItem; app.mobileApp.navigate('#components/worksPlans1/trainingTaskKGartenDetails.html?uid=' + e.dataItem.uid); }, itemClick4: function (e) { var dataItem = e.dataItem || homeModel.originalItem; app.mobileApp.navigate('#components/worksPlans1/directiveTaskKGartenDetails.html?uid=' + e.dataItem.uid); }, itemClick5: function (e) { var dataItem = e.dataItem || homeModel.originalItem; app.mobileApp.navigate('#components/worksPlans1/exerciseTaskKGartenDetails.html?uid=' + e.dataItem.uid); }, viewNameSub: function (subject1, num) { //SUBSTRING: //keeps here aar- it works!! // var newname = "`aarr1'".substring(1, 4) var aarr6 = {}; if (num == 0) { aarr6 = aarr; } if (num == 1) { aarr6 = aarr1; } if (num == 2) { aarr6 = aarr2; } if (num == 3) { aarr6 = aarr3; } if (num == 4) { aarr6 = aarr4; } if (num == 5) { aarr6 = aarr5; } for (var i in aarr6) { if (subject1 == i) return (aarr6) } }, //viewNameSub1: function (subject1) { // for (var i in aarr1) { // if (subject1 == i) // return (aarr1) // } //}, detailsShow: function (e) { var item = e.view.params.item; //dataSource; //dataSource = homeModel.get("dataSource"); //dataSource = homeModel.get("dataSource1"); alert(e.view.params.item) //var itemModel = dataSource.getByUid(item); //dataProvider.loadCatalogs().then(function _catalogsLoaded() { //var jsdoOptions = homeModel.get('_jsdoOptions1'), // jsdo = new progress.data.JSDO(jsdoOptions), // dataSourceOptions = homeModel.get('_dataSourceOptions1'), // dataSource; //dataSourceOptions.transport.jsdo = jsdo; //dataSource = new kendo.data.DataSource(dataSourceOptions); //dataSource.fetch(function () { // alert(dataSource.total()); //}); homeModel.set('currentItem', item); //alert(homeModel.currentItem.description) }, setCurrentItemByUid: function (uid) { var item = uid, dataSource = homeModel.get('dataSource'), itemModel = dataSource.getByUid(item); if (!itemModel.name) { itemModel.name = String.fromCharCode(160); } homeModel.set('originalItem', itemModel); homeModel.set('currentItem', homeModel.fixHierarchicalData(itemModel)); return itemModel; }, fixHierarchicalData: function (data) { var result = {}, layout = {}; $.extend(true, result, data); (function removeNulls(obj) { var i, name, names = Object.getOwnPropertyNames(obj); for (i = 0; i 0) { for (j = 0; j < srcObj.length; j++) { fix(srcObj[j], ltObj[0]); } } else { fix(srcObj, ltObj); } } } })(result, layout); return result; }, parent.set('homeModel', homeModel); parent.set('onShow', function (e) { var param = e.view.params.filter ? JSON.parse(e.view.params.filter) : null, isListmenu = false, backbutton = e.view.element && e.view.element.find('header [data-role="navbar"] .backButtonWrapper'); if (param || isListmenu) { backbutton.show(); backbutton.css('visibility', 'visible'); } else { if (e.view.element.find('header [data-role="navbar"] [data-role="button"]').length) { backbutton.hide(); } else { backbutton.css('visibility', 'hidden'); } } try { //i retreive few charts- for each one i need to define dataSourceOption.. etc.. dataProvider.loadCatalogs().then(function _catalogsLoaded() { var jsdoOptions = homeModel.get('_jsdoOptions'), jsdo = new progress.data.JSDO(jsdoOptions), dataSourceOptions = homeModel.get('_dataSourceOptions'), dataSource; dataSourceOptions.transport.jsdo = jsdo; dataSource = new kendo.data.DataSource(dataSourceOptions); //list of status var statusArr = jsdo.getPicklist_status().response.picklistData; // here replace "getPicklist_test_picklist" with the value mentioned in the JSDO operations(as the JSDO catalog is previewd,a query for picklist value is generated.) for (var i = 0; i < statusArr.length; i++) { object = statusArr; for (var property in object) { if (property == "id") { a = object[property]; } if (property == "name") { status[a] = object[property]; //Store the values in a map } } } //list of subject var subjectArr = jsdo.getPicklist_subject().response.picklistData; // here replace "getPicklist_test_picklist" with the value mentioned in the JSDO operations(as the JSDO catalog is previewd,a query for picklist value is generated.) for (var i = 0; i < subjectArr.length; i++) { object = subjectArr; for (var property in object) { if (property == "id") { a = object[property]; } if (property == "name") { aarr[a] = object[property]; //Store the values in a map } } } dataSource.sort({ field: "dueDate", dir: "asc" }); homeModel.set('dataSource', dataSource); //sessionStorage.setItem("subjectArray", JSON.stringify(subjectArr)); fetchFilteredData(param); }); dataProvider.loadCatalogs().then(function _catalogsLoaded() { var jsdoOptions1 = homeModel.get('_jsdoOptions1'), jsdo1 = new progress.data.JSDO(jsdoOptions1), dataSourceOptions1 = homeModel.get('_dataSourceOptions1'), dataSource1; dataSourceOptions1.transport.jsdo = jsdo1; dataSource1 = new kendo.data.DataSource(dataSourceOptions1); var subjectArr = jsdo1.getPicklist_subject().response.picklistData; // here replace "getPicklist_test_picklist" with the value mentioned in the JSDO operations(as the JSDO catalog is previewd,a query for picklist value is generated.) for (var i = 0; i < subjectArr.length; i++) { object = subjectArr; for (var property in object) { if (property == "id") { a = object[property]; } if (property == "name") { aarr1[a] = object[property]; //Store the values in a map } } } dataSource1.sort({ field: "dueDate", dir: "asc" }); homeModel.set('dataSource1', dataSource1); //fetchFilteredData(param); }); dataProvider.loadCatalogs().then(function _catalogsLoaded() { var jsdoOptions2 = homeModel.get('_jsdoOptions2'), jsdo2 = new progress.data.JSDO(jsdoOptions2), dataSourceOptions2 = homeModel.get('_dataSourceOptions2'), dataSource2; dataSourceOptions2.transport.jsdo = jsdo2; dataSource2 = new kendo.data.DataSource(dataSourceOptions2); var subjectArr = jsdo2.getPicklist_type_of_drill().response.picklistData; // here replace "getPicklist_test_picklist" with the value mentioned in the JSDO operations(as the JSDO catalog is previewd,a query for picklist value is generated.) for (var i = 0; i < subjectArr.length; i++) { object = subjectArr; for (var property in object) { if (property == "id") { a = object[property]; } if (property == "name") { aarr2[a] = object[property]; //Store the values in a map } } } dataSource2.sort({ field: "startDate", dir: "asc" }); homeModel.set('dataSource2', dataSource2); //dataSource2.fetch(function () { // //localStorage.setItem("Sum1Neshek", dataSource1.total()); // alert(dataSource2.total()); //}); }); dataProvider.loadCatalogs().then(function _catalogsLoaded() { var jsdoOptions3 = homeModel.get('_jsdoOptions3'), jsdo3 = new progress.data.JSDO(jsdoOptions3), dataSourceOptions3 = homeModel.get('_dataSourceOptions3'), dataSource3; dataSourceOptions3.transport.jsdo = jsdo3; dataSource3 = new kendo.data.DataSource(dataSourceOptions3); var subjectArr = jsdo3.getPicklist_subject().response.picklistData; // here replace "getPicklist_test_picklist" with the value mentioned in the JSDO operations(as the JSDO catalog is previewd,a query for picklist value is generated.) for (var i = 0; i < subjectArr.length; i++) { object = subjectArr; for (var property in object) { if (property == "id") { a = object[property]; } if (property == "name") { aarr3[a] = object[property]; //Store the values in a map } } } dataSource3.sort({ field: "dueDate", dir: "asc" }); homeModel.set('dataSource3', dataSource3); }); dataProvider.loadCatalogs().then(function _catalogsLoaded() { var jsdoOptions4 = homeModel.get('_jsdoOptions4'), jsdo4 = new progress.data.JSDO(jsdoOptions4), dataSourceOptions4 = homeModel.get('_dataSourceOptions4'), dataSource4; dataSourceOptions4.transport.jsdo = jsdo4; dataSource4 = new kendo.data.DataSource(dataSourceOptions4); var subjectArr = jsdo4.getPicklist_subject().response.picklistData; // here replace "getPicklist_test_picklist" with the value mentioned in the JSDO operations(as the JSDO catalog is previewd,a query for picklist value is generated.) for (var i = 0; i < subjectArr.length; i++) { object = subjectArr; for (var property in object) { if (property == "id") { a = object[property]; } if (property == "name") { aarr4[a] = object[property]; //Store the values in a map } } } dataSource4.sort({ field: "dueDate", dir: "asc" }); homeModel.set('dataSource4', dataSource4); }); dataProvider.loadCatalogs().then(function _catalogsLoaded() { var jsdoOptions5 = homeModel.get('_jsdoOptions5'), jsdo5 = new progress.data.JSDO(jsdoOptions5), dataSourceOptions5 = homeModel.get('_dataSourceOptions5'), dataSource5; dataSourceOptions5.transport.jsdo = jsdo5; dataSource5 = new kendo.data.DataSource(dataSourceOptions5); var subjectArr = jsdo5.getPicklist_type_of_drill().response.picklistData; // here replace "getPicklist_test_picklist" with the value mentioned in the JSDO operations(as the JSDO catalog is previewd,a query for picklist value is generated.) for (var i = 0; i < subjectArr.length; i++) { object = subjectArr; for (var property in object) { if (property == "id") { a = object[property]; } if (property == "name") { aarr5[a] = object[property]; //Store the values in a map } } } //try to merge- homeModel.set('dataSource5', dataSource5+dataSource3); dataSource5.sort({ field: "startDate", dir: "asc" }); homeModel.set('dataSource5', dataSource5); }); } catch (e) { alert("problem with loading data") } //try to merge dataSources var data1 = dataSource.data(); //First data source data dataSource10 = dataSource.data(); alert(dataSource10 + "dataSource10") dataSource.fetch(function () { alert(dataSource.total() + "dataSource.total()"); }); //alert(data1+"data1") var data2 = dataSource1.data(); //Second data source data //alert(data2 + "data2") ////concat two array data by converting kendo model to actual json var mergedData = data1.toJSON().concat(data2.toJSON()); //alert(mergedData +"mergedData") var newDataSource = new kendo.data.DataSource({ data: mergedData, sort: { field: 'dueDate', dir: 'asc' }, schema: { model: { fields: { dueDate: { type: 'date' }, // name: { type: 'string' }, } } } }); //alert(newDataSource + "newDataSource") //newDataSource.fetch(function () { // alert(newDataSource.total() + "newDataSource.total()"); // var data = newDataSource.view(); // console.log(data[0].dueDate); //}); }); })(app.allWorkPlans);
Continue reading...
Continue reading...