Breeze query with multiple conditions - breeze

How to write a breeze query with 2 'where' conditions?
the following doesn't work:
var query = breeze.EntityQuery.from("Boilers")
.where('boilerMakeID', '==', $rootScope.boilerMakeID)
.and('actueel', '==', true);

Use Predicates...
http://www.breezejs.com/sites/all/apidocs/classes/Predicate.html
var pred1 = Predicate.create("boilerMakeID", "==", $rootScope.boilerMakeID);
var pred2 = Predicate.create("actueel", "==", true);
var newPred = pred1.and(pred2);
var query = breeze.EntityQuery.from("Boilers").where(newPred)

Another way to use predicates...
var p1=new breeze.Predicate("boilerMakeId","==",$rootScope.boilerMakeID);
var p2=new breeze.Predicate("actueel","==",true);
var predicate=p1.and(p2);
var query=breeze.EntityQuery.from("Boilers").where(predicate);

Related

Skip empty value in Google Sheets

I have running script in google sheets for submitting data, but I have no idea how to skip empty values
Here is my script :
function SubmitData() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var formS = ss.getSheetByName("FORM");
var dataS= ss.getSheetByName("DATA");
var values = formS.getRange(8,1,20,5).getValues();
dataS.getRange(dataS.getLastRow()+1,3,20,5).setValues(values);
}
Thank You
var values = formS.getRange(8,1,20,5).getValues();
values = values.filter(e=>e.join('') !== '');
dataS.getRange(dataS.getLastRow()+1,3,values.length,5).setValues(values);

Using Script to add an ='Sheet1!'D3 formula that has a sheet name that is pulled within the script

I have this:
var app = SpreadsheetApp;
var activesheet = app.getActiveSpreadsheet().getActiveSheet();
var RecipeList = app.getActiveSpreadsheet().getSheetByName('Recipe List')
var recipename = activesheet.getRange('D3').getValue();
var costperserve = activesheet.getRange('J5').getValue();
var foodcostpercentage = activesheet.getRange('J6').getValue();
var sellingprice = activesheet.getRange('J7').getValue();
var grossprofit = activesheet.getRange('J10').getValue();
var spreadsheetname = activesheet.getSheetName() ;
var Last = RecipeList.getLastRow();
RecipeList.getRange(Last+1,1,1,1).setValue(recipename), {contentsOnly:true};
RecipeList.getRange(Last+1,2,1,1).setValue(costperserve), {contentsOnly:true};
RecipeList.getRange(Last+1,3,1,1).setValue(foodcostpercentage),
{contentsOnly:true};
RecipeList.getRange(Last+1,4,1,1).setValue(sellingprice), {contentsOnly:true};
RecipeList.getRange(Last+1,5,1,1).setValue(grossprofit), {contentsOnly:true};
RecipeList.getRange(Last+1,6,1,1).setValue(spreadsheetname),
{contentsOnly:true};
Though I want the values to = ( = 'spreadsheetname' !D3) as a pose to just the value so I can change the value and it is updated.
There is a setFormula() method that you can use exactly like setValue(), but it's not necessary. You can use setValue() just as well here.
It looks like you're trying to pass an option of {contentsOnly:true} into setValue(), but that's not valid. As you can see in the linked documentation, this method doesn't allow any options. Moreover, it doesn't allow that particular option because it affects the contents only anyway.
Try this example code:
function insertFormulaTest() {
var ss = SpreadsheetApp.getActive();
var sourceSheet = ss.getSheetByName("Source Sheet");
var sourceCell = sourceSheet.getRange("D3");
var formula = "='" + sourceSheet.getName() + "'!" + sourceCell.getA1Notation(); // "='Source Sheet'!D3"
var destinationSheet = ss.getSheetByName("Destination Sheet");
destinationSheet.getRange("A1").setValue(formula);
}

Google Spreadsheet Script: setValue

This is my code (it is fully working as intended).
function concatenate() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Responses");
var datarange = sheet.getDataRange();
var lastrow = datarange.getLastRow();
for (i=lastrow;i>=2;i--) {
var datad = sheet.getRange(i, 4).getValue();
var datae = sheet.getRange(i, 5).getValue();
var concatde = sheet.getRange(i, 4).setValue(sheet.getRange(i, 1).getValue());
}
}
However my question is regarding the line var concatde = sheet.getRange(i, 4).setValue(sheet.getRange(i, 1).getValue()); in my code.I wish to add a string at the end of the setValue as well shown in this line.
var concatde = sheet.getRange(i, 4).setValue(sheet.getRange(i, 1).getValue(), "A");
However, when I run it with the string "A", I get this error message:
Cannot find method setValue(object,string). (line 12, file "Code")
Any suggestions for me to be able to have a string at the end of it as well?
From what I can see setValue() only takes in one parameter.
Google Apps Script is just javascript so you can do something like below:
var concatde = sheet.getRange(i, 4).setValue(sheet.getRange(i, 1).getValue() + "A");
Note the '+' after getValue().

ko.mapping is always an empty array

Here is what I am returning from my controller:
var states = _dc.States.ToList();
var serializer = new JavaScriptSerializer();
ViewBag.StateList = serializer.Serialize(states);
My JS:
var stateList = #Html.Raw(ViewBag.StateList);
var stateListModel = ko.mapping.fromJS(stateList);
Is I do a console.log on stateListModel, it is always [], but stateList is a complete array with all the data.
The ko.mapping result is not an empty array, it is a function.
As nemesv's comment says, you have to do this:
var stateListModel = ko.mapping.fromJS(stateList);
var realArray = stateListModel();

get values of date-input-boxes from rangeSelector

Is it possible to get the values of the date-input-boxes from rangeSelector?
var chart = new Highcharts.StockChart(chartingOptions);
...
var zoomStartEpochTime = chart.rangeSelector.leftBox.HCTime;
var zoomEndEpochTime = chart.rangeSelector.rightBox.HCTime;
Alternatively you can query the xAxis's extreme values for the same
var zoomStartEpochTime = chart.xAxis[0].getExtremes().min;
var zoomEndEpochTime = chart.xAxis[0].getExtremes().max;
Yes you can get these values. If you are using JQuery:
var minDate = $('input.highcharts-range-selector:eq(0)').val();
var maxDate = $('input.highcharts-range-selector:eq(1)').val();

Resources