jQWidgets Forums
Forum Replies Created
-
Author
-
May 28, 2014 at 1:45 pm in reply to: Display "today" if the event is today Display "today" if the event is today #55036
Thanks for your fast reply Peter. I’ll give it a shot!
cheers
AndyApril 24, 2014 at 7:20 am in reply to: Get json from s https url (ssl) Get json from s https url (ssl) #53521For future visitors: I did a work around using curl by downloading the file to the server and then access it locally via json:
<?php $ch = curl_init(); $source = "https://app.psycho.unibas.ch/raumbuchung/index/abjson"; // url for the json from the https server curl_setopt($ch, CURLOPT_URL, $source); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); $file = fopen("abjson.json", "w+"); //save it locally as abjson.json, make it writable! fputs($file, $data); fclose($file); ?>
Then use
var source = { [...] url: "abjson.json", };
April 9, 2014 at 2:40 pm in reply to: Only display entries with dates in the future. Only display entries with dates in the future. #52801Ok, I looked at it again, and now it works.
For future vistors, that’s how I solved it:var dataAdapter = new $.jqx.dataAdapter(source, { beforeLoadComplete: function(records) { var data = new Array(); for (var i = 0; i < records.length; i++) { var source = records[i]; var userDate = source.start; var date = new Date(); var today = date; if (userDate >= today) { data.push(source) } else { } } return data; } });
Best,
AndyMarch 31, 2014 at 2:33 pm in reply to: Only display entries with dates in the future. Only display entries with dates in the future. #52256Hi Peter
thanks for your answer. I read the article and did the following:
var source = { datatype: "json", datafields: [ {name: 'title', type: 'string'}, {name: 'room_name', type: 'string'}, {name: 'room_number', type: 'string'}, {name: 'start', type: 'date', format: "yyyy-MM-dd HH:mm"}, {name: 'end', type: 'date', format: "yyyy-MM-dd HH:mm"}, {name: 'user', type: 'string'} ], root: "record", record: "", // id: '', url: "test.json", sortcolumn: 'start', sortdirection: 'asc' }; var dataAdapter = new $.jqx.dataAdapter(source, { beforeLoadComplete: function(records) { for (var i = 0; i < records.length; i++) { var source = records[i]; var userDate = source.start; var date = new Date(); var day = date.getDate(); var month = date.getMonth() + 1; //Months are zero based var year = date.getFullYear(); var hour = date.getHours(); var min = date.getMinutes(); // tell the proper format var today = '' + year + '-' + (month <= 9 ? '0' + month : month) + '-' + (day <= 9 ? '0' + day : day) + ' ' + (hour <= 9 ? '0' + hour : hour) + ' ' + (min <= 9 ? '0' + min : min); if (userDate >= today) { return records; } } } });
This does not the trick – the output is still everything. If I edit the if-condition to this:
var empty = []; if (userDate >= today) { return records; } else { return empty; }
It displays “No data to display”.
I think I misunderstood the beforeLoadComplete :-/cheers
January 29, 2014 at 11:01 am in reply to: Get json from s https url (ssl) Get json from s https url (ssl) #48597Thanks Peter, I’ll read this and speak with the webadmin if it’s even possible. He might have missed to configure the server properly so I can use jsonp. I’ll report back as soon as I have figured it out.
January 29, 2014 at 10:45 am in reply to: Get json from s https url (ssl) Get json from s https url (ssl) #48594Hello Peter,
you mean something like:url: "https://app.psycho.unibas.ch/raumbuchung/overview/json/", data: { featureClass: "P", style: "full", maxRows: 50 }, formatdata: function(data) { return "my data"; }
Well, it still does not work. I’m kinda new to this stuff … :-/
Best,
AndyJanuary 29, 2014 at 10:08 am in reply to: Get json from s https url (ssl) Get json from s https url (ssl) #48589Hi Peter
thanks for your answer. Indeed I tried jsonp, but it still won’t work, unfortunately. I just post my code here, maybe the error is obvious for an expert<!DOCTYPE html> <html lang="en"> <head> <title id='Description'>In this example the Grid is bound to a Remote Data.</title> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.columnsresize.js"></script> <script type="text/javascript"> $(document).ready(function() { // prepare the data var source = { datatype: "jsonp", datafields: [ {name: 'id', type: 'string'}, {name: 'name', type: 'string'}, {name: 'type', type: 'string'}, {name: 'seats', type: 'string'}, {name: 'building', type: 'string'}, {name: 'device', type: 'string'} ], url: "https://app.psycho.unibas.ch/raumbuchung/overview/json/", root: 'data', id: 'id' }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid( { source: source, columnsresize: true, columns: [ {text: 'Country Name', datafield: 'id', width: 200}, {text: 'City', datafield: 'name', width: 170}, {text: 'Population', datafield: 'type', width: 170}, {text: 'Continent Code', datafield: 'seats', minwidth: 110}, {text: 'Continent Code', datafield: 'building', minwidth: 110}, {text: 'Continent Code', datafield: 'device', minwidth: 110} ] }); }); </script> </head> <body class='default'> <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;"> <div id="jqxgrid"></div> </div> </body> </html>
and the data source from https://app.psycho.unibas.ch/raumbuchung/overview/json/ looks like this:
[{"id":"1","name":"64a - 01","type":"Seminarraum","seats":"25","building":"Nebenhaus","devices":[]},{"id":"2","name":"64a - 02","type":"Seminarraum","seats":"25","building":"Nebenhaus","devices":[]},{"id":"3","name":"64a - 03","type":"Seminarraum","seats":"25","building":"Nebenhaus","devices":[]},{"id":"4","name":"64a - 04","type":"Seminarraum","seats":"25","building":"Nebenhaus","devices":[]},{"id":"5","name":"64a - 07","type":"Seminarraum","seats":"35","building":"Nebenhaus","devices":[]},{"id":"6","name":"64a - 08","type":"Seminarraum","seats":"35","building":"Nebenhaus","devices":[]},{"id":"7","name":"64a - 09","type":"Seminarraum","seats":"35","building":"Nebenhaus","devices":[]},{"id":"8","name":"Computer-Schulungsraum","type":"Computerraum","seats":"20","building":"Hinterhaus","devices":[]},{"id":"9","name":"Ecolab 1","type":"Labor","seats":"8","building":"Hinterhaus","devices":[]},{"id":"10","name":"H\u00f6rsaal 010","type":"H\u00f6rsaal","seats":"88","building":"Hinterhaus","devices":[]},{"id":"11","name":"Labor Sozialpsychologie","type":"Labor","seats":"3","building":"Nebenhaus","devices":[]},{"id":"12","name":"Labor Sozialpsychologie","type":"Therapieraum","seats":"6","building":null,"devices":[]},{"id":"13","name":"Medienbearbeitung","type":"Computerraum","seats":"2","building":"Vorderhaus","devices":[]},{"id":"14","name":"N-Lab 1 - EEG und Eyetracking","type":null,"seats":"1","building":"Vorderhaus","devices":[]},{"id":"15","name":"N-Lab 2 - Physiologie","type":null,"seats":"1","building":"Vorderhaus","devices":[]},{"id":"16","name":"N-Lab 3 - Sensorische Testungen","type":null,"seats":"2","building":"Vorderhaus","devices":[]},{"id":"17","name":"Sitzungzimmer KPE\/KPP","type":"Labor","seats":"12","building":null,"devices":[]},{"id":"18","name":"UPD Erwachsenenzimmer","type":"Therapieraum","seats":"4","building":"Vorderhaus","devices":[]},{"id":"19","name":"UPD Kinder-\/ Jugendlichenzimmer","type":"Therapieraum","seats":"4","building":"Vorderhaus","devices":[]},{"id":"20","name":"UPD Testzimmer","type":"Therapieraum","seats":"4","building":"Vorderhaus","devices":[]},{"id":"21","name":"Usability Labor","type":"Therapieraum","seats":"4","building":"Vorderhaus","devices":[]},{"id":"22","name":"Verhaltenslabor KPE","type":"Labor","seats":"4","building":"Vorderhaus","devices":[]},{"id":"23","name":"Verhaltenslabor KPE","type":"Therapieraum","seats":"9","building":"Vorderhaus","devices":[]},{"id":"24","name":"Verhaltenslabor KPE","type":"Labor","seats":"4","building":"Vorderhaus","devices":[]},{"id":"25","name":"Verhaltenslabor KPP","type":null,"seats":"4","building":"Vorderhaus","devices":[]},{"id":"26","name":"Verhaltenslabor KPP","type":null,"seats":"6","building":"Vorderhaus","devices":[]}]
Help will be much appreciated.
-
AuthorPosts