I tried this :
$row = JTable::getInstance('K2Item', 'Table');
$row->load($myId);
//change something
$row->title = 'New title';
$row->save(); // doesn't work
$row->checkin(); // doesn't work either
I was going also through most of the K2 code but it seems to rely on request variables and I have a hard time to understand that code at all.
Does anyone knows what's the right procedure?
thanks
Related
I try to use Google Script Apps (instead of VBA which I am more used to) and managed now to create a loop over different spreadsheets (and not only different sheets in one document) using the forEach function.
(I tried with a for (r=1;r=lastRow; r++) but I did not manage).
It is working now defining the array for the sheetnames manually:
var SheetList = ["17DCu1nyyX4a6zCkkT3RfBSfo-ghoc2fXEX8chlVMv5k", "1rRGQHs_JShPSBIGFCdG6AqXM967JFhdlfQ92cf5ISL8", "1pFDyXgYmvC5gnN5AU5xJ8vGiihwtubcbG2n4LPhPACQ", "1mK_X4Q7ysJQTt8NZoZASBE5zuUllPmmWSJsxu5Dnu9Y", "1FpjIGWTG5_6MMYJF72wvoiBRp_Xlt5BDpzvSZKcsU"]
And then for information the loop:
SheetList.forEach(function(r) {
var thisSpreadsheet = SpreadsheetApp.openById(r)
var thisData = thisSpreadsheet.getSheetByName('Actions').getDataRange()
var values = thisData.getValues();
var toWorksheet = targetSpreadsheetID.getSheetByName(targetWorksheetName);
var last = toWorksheet.getLastRow ()+ 1
var toRange = toWorksheet.getRange(last, 1, thisData.getNumRows(), thisData.getNumColumns())
toRange.setValues(values);
})
Now I want to create the definition of the array "automatically" out of the spreadsheet 'List' where all spreadsheets which I want to loop are listed in column C.
I tried several ideas, but always failed.
Most optimistic ones were:
var SheetList = targetSpreadsheetID.getSheetByName('List').getRange(2,3,lastRow-2,3).getValues()
And I also tried with the array-function:
var sheetList=Array.apply(targetSpreadsheetID.getSheetByName('List').getRange(2,3,lastRow-2,3))
but all without success.
It should be possible normally in more or less one single line to import the array from the speadsheet to the Google apps scripts?
I would very much appreciate if someone could please give me a hint where my mistake is.
Thank you very much.
Maria
I still did not manage to put the array as I wanted it initially, but now I found a workable solution with the For Loop which I want to share here in case someone is looking for a similar solution (and then finds at least my workaround ;) )
for (i=2; i<lastRow;i++){
var SheetList = targetSpreadsheetID.getSheetByName('List').getRange(i,3).getValues()
Logger.log(SheetList);
var thisSpreadsheet = SpreadsheetApp.openById(SheetList);
... // the rest identical to loop above...
Don't hesitate to add your comments or advice anyhow, but I will mark the question as closed.
Thanks a lot.
Maria
I want to display data from Parse in a list from GamesScores class using Container in Codename One, this is what I've tried so far and it's not showing anything nor giving any errors:
Container container = findListCont();
container.setLayout(BoxLayout.y());
container.setScrollableY(true);
ParseQuery<ParseObject> query = ParseQuery.getQuery("GameScore");
List<ParseObject> results = (List<ParseObject>) query.find();
System.out.println("Size: " + results.size());
container.addComponent(results, f);
Please help me out, I'm a new in Codename One. If there tutorials on it, please share or anything to help me achieve the desired results.
I'm actually shocked this isn't failing. You are using the add constraint to place the object result as a constraint and you add the form object into the container...
You need to loop over the results and convert them to components to add into the layout. It also seems that you are using the old GUI builder which I would recommend against.
Generally something like this rough pseudo code should work assuming you are using a box Y layout:
for(ParseObject o : results) {
MultiButton mb = new MultiButton(o.getDisplayValue());
f.add(mb);
}
f.revalidate();
I am trying to merge two jsons into one but can't make it work. I manage to retrieve the data I need from both get, but I have troubles manipulating the jsons.
I planned on using two for loops but it doesn't work :
$scope.coursesJson = $http.get('https://api.myjson.com/bins/18zi3');
$scope.reviewsJson = $http.get('https://api.myjson.com/bins/52toz');
$q.all([$scope.coursesJson, $scope.reviewsJson]).then(function (values){
$scope.coursesJson = values[0];
$scope.reviewsJson = values[1];
for(i = 0;i<$scope.coursesJson.length;i++){
for(j = 0;j<$scope.reviewsJson.length;j++){
if($scope.coursesJson[i].name = $scope.reviewsJson[j].name){
$scope.coursesJson[i].reviews.push($scope.reviewsJson[j]);
}
}
}
console.log($scope.coursesJson);
});
Using the console, I can visualise the data but $scope.coursesJson.length is undefined and I don't understand why.
Maybe I don't understand $q well ?
EDIT :
Here is an example of the elements you could find in the coursesJson file I get() :
[{"code":"123 ","name":"Acteurs","courseContentGrade":null,"courseTeachingGrade":null,"courseAverage":null,"reviews":null},
{"code":"1234","name":"Advanced Excel","courseContentGrade":null,"courseTeachingGrade":null,"courseAverage":null,"reviews":null}]
And an example of the elements you could find in the reviewsJson file I get() :
[{"code":"123 ","name":"Acteurs","professor":"Lalala","contentReview":"C'est très réussi.","teachingReview":"charismatique","contentGrade":8,"teachingGrade":8,"average":8,"trimester":"T2","day":"Jeudi / Thursday","time":"9h-12h","round":"1er tour","bet":21,"year":"2014/2015","upvotes":"0","author":"Piranha","passed":null},
{"code":"123 ","name":"Acteurs","professor":"LAlalalala","contentReview":"Très intéressant !","teachingReview":"Disponible, claire.","contentGrade":8,"teachingGrade":8,"average":8,"trimester":"T2","day":"Jeudi / Thursday","time":"9h-12h","round":"1er tour","bet":25,"year":"2014/2015","upvotes":"0","author":"Piranha","passed":null}]
I would like to add the elements found in the reviewsJson to the reviews field of the elements of coursesJson. Could that be the problem ? I thought that using the push() method would create the array, but maybe I need to change all "reviews":null to "reviews":[] in coursesJson ?
I went to the url https://api.myjson.com/bins/ID1 and it's not an array, but an object. Instead of $scope.coursesJson.length I think you shouldbe doing $scope.coursesJson.tracks.length
I solved my issue really easyly and my question was actually pretty stupid.
What I tried to achieve didn't have its place on the front but on the backend.
Okay, I've been bashing my head bloody on this one:
I have the following JSON coming back from the server:
{
"SendDate" : "2015-03-16T22:48:27.747",
"SendTo" : {
"ContactIds" : ["28a24538-cdfc-4453-920d-86f57d7eaf22"],
"GroupIds" : []
},
"Message" : "MEETING TIME!!!!!"
}
I have checked this with several REST clients - this IS what comes back.
I have AngularJS "getting" this with an $http.get() operation, but I get an undefined on the "ContactIds" value - so, what I see in the JS Console is:
SendDate : "2015-03-16T22:48:27.747"
SendTo:
ContactIds: Array[1]
0: undefined
length: 1
I have NO IDEA what can be causing this.
Any ideas?
UPDATE:
I have attached an interceptor and intercepted the response and the result is the same when I feed the data to the console - but when I use:
JSON.stringify(data)
I can see that the Data in the Array is THERE!
UPDATE 2:
Okay now this is driving me nuts. I have played with the interceptor and if I stringify the response and then use JSON.parse() - it works fine, but when I pass the response through, it comes out messed up again.
I traced it through angular's parsing process all the way to the "fromJson()" function. (code below:) It comes into the function as a string. (Now here's the Bizzarro part)
I altered the code like this:
function fromJson(json) {
var obj1 = JSON.parse(json);
console.log("Obj1:");
console.log(obj1);
//my altered angular code
var obj2 = isString(json) ? JSON.parse(json) : json;
console.log("Obj2:");
console.log(obj2);
// Pass to program...
return obj1;
//return obj2;
/* original angular code:
return isString(json)
? JSON.parse(json)
: json;
*/
}
If I run it and return obj1, the console logs obj1's ContactIds "0" index as "undefined" - but obj2 logs as "28a24538-cdfc-4453-920d-86f57d7eaf22".
"GREAT!", I'm thinking - so I return obj2, but now it logs undefined but obj1's "0" index is now the correct value. (WTH?)
So I reverse the code, just to see, and Return obj1 - and I'll be damned - obj2 returns "28a24538-cdfc-4453-920d-86f57d7eaf22" and obj1 is undefined. (It's like teasing a monkey.)
It HAS to be something later on in the pipeline that is doing it - OR - it may have something to do with the array being GUID strings - but I use GUID strings elsewhere with no problems.
It could also be another "angular process" that I'm unaware of that is causing this - angular is quite impressive.
Either way, I'm super-confused.
This is so stupid - I'm surprised that an array of strings is such a difficulty - and what's worse, it seems I'm the only one having this problem. (I researched this for six hours yesterday...)
Any other ideas, guys?
OH MY GOD I'M SO STUPID!!!
First I'd like to thank everyone for trying to help me.
The answer is this - there was no problem, that is, not with Angular or its parser.
The Problem is that the Console was logging transformed data, which had an error at MY controller. The data on MY end was not matching the data in the list that I had in my controller - (Database Error).
BOTTOM LINE:
If you have this error pop up, do NOT troubleshoot from the top-down - troubleshoot from the bottom-up.
Angular has many checks and balances - if you don't get "bleeding failures" throughout the program, chances are the error is in YOUR code.
Thank you everyone for your help.
I am not familiar with .NET coding.
However, I must create DZI sliced image assets on a shared server and am told that I can instantiate and use DeepZoomTools.dll.
Can someone show me a very simple DZI creation script that demonstrates the proper .NET coding technique? I can embellish as needed, I'm sure, but don't know where to start.
Assuming I have a jpg, how does a script simply slice it up and save it?
I can imagine it's only a few lines of code. The server is running IIS 7.5.
If anyone has a simple example, I'd be most appreciative.
Thanks
I don't know myself, but you might ask in the OpenSeadragon community:
https://github.com/openseadragon/openseadragon/issues
Someone there might know.
Does it have to be DeepZoomTools.dll? There are a number of other options for creating DZI files. Here are a few:
http://openseadragon.github.io/examples/creating-zooming-images/
Example of building a Seadragon Image from multiple images.
In this, the "clsCanvas" objects and collection can pretty much be ignored, it was an object internal to my code that was generating the images with GDI+, then putting them on disk. The code below just shows how to get a bunch of images from file and assemble them into a zoomable collection. Hope this helps someone :-).
CollectionCreator cc = new CollectionCreator();
// set default values that make sense for conversion options
cc.ServerFormat = ServerFormats.Default;
cc.TileFormat = ImageFormat.Jpg;
cc.TileSize = 256;
cc.ImageQuality = 0.92;
cc.TileOverlap = 0;
// the max level should always correspond to the log base 2 of the tilesize, unless otherwise specified
cc.MaxLevel = (int)Math.Log(cc.TileSize, 2);
List<Microsoft.DeepZoomTools.Image> aoImages = new List<Microsoft.DeepZoomTools.Image>();
double fLeftShift = 0;
foreach (clsCanvas oCanvas in aoCanvases)
{
//viewport width as a function of this canvas, so the width of this canvas is 1
double fThisImgWidth = oCanvas.MyImageWidth - 1; //the -1 creates a 1px overlap, hides the seam between images.
double fTotalViewportWidth = fTotalImageWidth / fThisImgWidth;
double fMyLeftEdgeInViewportUnits = -fLeftShift / fThisImgWidth; ; //please don't ask me why this is a negative numeber
double fMyTopInViewportUnits = -fTotalViewportWidth * 0.3;
fLeftShift += fThisImgWidth;
Microsoft.DeepZoomTools.Image oImg = new Microsoft.DeepZoomTools.Image(oCanvas.MyFileName.Replace("_Out_Tile",""));
oImg.ViewportWidth = fTotalViewportWidth;
oImg.ViewportOrigin = new System.Windows.Point(fMyLeftEdgeInViewportUnits, fMyTopInViewportUnits);
aoImages.Add(oImg);
}
// create a list of all the images to include in the collection
cc.Create(aoImages, sMasterOutFile);