I'm trying to implement filtering on a table. This involves the getBinding() function.
getBinding() works fine with a single table - id of "stock_table".
// update list binding
var list = this.getView().byId("stock_table");
var binding = list.getBinding("items");
However, when accessing multiple generated tables of the same Id, the getBinding() returns 'undefined'
How do I apply a filter to multiple tables with the same id?
Solution was this...
Thanks for your help!
// Filter every table with the group container
var oGroupContainer = this.getView().byId('groups_container');
var oGroupItems = oGroupContainer.getRows();
_.each(oGroupItems, function (oCategory) {
var content = oCategory.getAggregation("content");
var itemBinding = content[0].getBinding("items");
itemBinding.filter(aFilters);
});
Related
I am working with two collections of satellite data. I want to select specific bands from "collection 1", join them to "collection 2", and then run a function. Unfortunately, the function does not work with the joined data, although it works for "collection 1".
Here is an example just using B10 of Sentinel-2
//identifying area and date
var geometry = ee.Geometry.Point([4,45]);
Map.centerObject(geometry,10);
var start = '2019-03-10';
var end = '2019-05-10';
//my function
function testing(img){
img = img.updateMask(img.select(['B10']).gt(200).focal_min(2).focal_max(2).not());
return img;
}
//my two collections
var collection1 = ee.ImageCollection('COPERNICUS/S2').filterDate(start,end)
.filterBounds(geometry);
var B10s=collection1.select('B10');
//print('B10s',B10s);
var collection2 = ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate(start,end)
.filterBounds(geometry);
// joining the collections
var filtering = ee.Filter.equals({
leftField: 'system:time_start',
rightField: 'system:time_start'
});
var simpleJoin = ee.Join.inner();
var innerJoin = simpleJoin.apply(collection2, B10s, filtering);
var joined = innerJoin.map(function(feature) {
return ee.Image.cat(feature.get('primary'), feature.get('secondary'));
});
print('Joined', joined);
//just to visualize one image
//var coll1 = ee.Image(collection1.first());
//Map.addLayer(coll1, {bands:['B2'], min:0, max:5000},'B2Coll1 test');
//running the function for collection 1 works
var test = collection1.map(testing);
var tess = ee.Image(test.first());
Map.addLayer(tess, {bands:['B2'], min:0, max:5000},'B2 test');
//here when running with the joined collection, there is a problem
var TestingJoined = joined.map(testing);
The error is: img.select(...).gt is not a function
How do I make this work?
When you debug, does the join work as intended? Is there any issue with the datetimes being too-precise to allow a full join?
The second route I would go down is ensuring that the joined object is identical to collections. I doubt this would be the case without you casting it or something (though I'm not familiar with this library). Your "testing" function that you're mapping to these collections may work with just the unjoined ones. If you provide the actual 'Problem' or error output that would be immensely helpful.
Ok. I solved it. Thank you for your input.
I needed to use a cast in the function. Now it works.
function testing(img){
img = ee.Image(img).updateMask(ee.Image(img).select(['B10']).gt(200).focal_min(2).focal_max(2).not());
return img;
}
need some help with script on google sheets
I'm having some issues to try to use "setVisibleValues" and I got an error saying "Exception: Visible values are not currently supported. As an alternative specify a list of hidden values that excludes the values that should be visible.". But my problem is, I've a huge number of employee names on a list, and I wanna filter just based in one person.
I cant show some information, but the thing is: "I just wanna filter one value, and I don't know how to do it using "setHiddenValues".
function Filtersheet() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('A3:S').activate();
spreadsheet.getRange('H3').activate();
var criteria = SpreadsheetApp.newFilterCriteria()
.setHiddenValues([''])
var criteria = SpreadsheetApp.newFilterCriteria()
.setVisibleValues(['tayzer'])
.build();
spreadsheet.getActiveSheet().getFilter().setColumnFilterCriteria(8, criteria);
}
Lets say that the names of the Employees are : jorge, lucas, nuno, fernando, marta, beatriz, tayzer, larissa, and I wanna use the filter script to only show on the column the information related to tayzer
But my way to change the filter employee will be on a cell outside the script (cause I've around 200 employees)
Thanks in advance for the help
try this
function setFilter() {
// replace 'sheet name' with you sheet
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('sheet name');
var range = ss.getDataRange();
var filter = range.getFilter() || range.createFilter()
var criteria = SpreadsheetApp.newFilterCriteria().whenTextContains('tayzer');
filter.setColumnFilterCriteria(8, criteria);
}
if i am not wrong if you put "jorge" in cell_C4 you want it to filter "jorge" in column E, if so try below code.
function setFilter() {
// replace 'sheet name' with you sheet
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('sheet name');
var range = ss.getDataRange();
var filter = range.getFilter() || range.createFilter()
var criteria = SpreadsheetApp.newFilterCriteria().whenTextContains(ss.getRange('C4').getValue()).build();
filter.setColumnFilterCriteria(8,criteria)
}
I have binded a Table using oData like below.
<Table id="myTableID"
class="sapUiResponsiveMargin"
items="{Items}"
noDataText="{i18n>NoDataText}"
updateFinished="onUpdateFinished"
width="auto">
Now I need to retrieve this oData model from the view rather than calling the web service again.
I have tried the below,
var path = this.getView().getElementBinding().getPath();
var oModel = this.getView().getModel();
which returns the model from the parent view.
Is there a way to achieve this?
Just use this.getView().byId("myTableID").getModel();
I assume that you want only the items that are bound to the table.
var sPath = oTable.getBindingPath("items");
This gives you the path that you have bound to the items aggregation.
var oModelObject = oTable.getModel().getProperty(sPath);
This fetches only the table bound objects from your model
Edit oTable is your table object. var oTable = this.getView().byId("myTableID");
I'm using: ASP.NET MVC, MySql, Dapper.NET micro-orm
I made a stored procedure with 3 SELECTs, two of which returns lists and the third one returns an integer.
Here is my code:
using (var conn = new MySqlConnection(GetConnectionString()))
{
var readDb = conn.QueryMultiple(storedProcedure, parameters, commandType: CommandType.StoredProcedure);
var result = new someView
{
TopicsList = readDb.Read<ITopic>().ToList(),
TopTopicsList = readDb.Read<IMessage>().ToList(),
TopicsCount = readDb.Read<int>().Single()
};
return result;
}
In ITopic I have TopicId, in IMessage I have MessageId.
And here's the error:
When using the multi-mapping APIs ensure you set the splitOn param if you have keys other than Id Parameter name: splitOn
I tried adding splitOn on both QueryMultiple and Read, and nigher accepted it.
Though I dont understand why I need splitOn? can't dapper see that I have three separate SELECTs? When using conn.Read(storedProcedure,parameters) on each of the selects separately (instead of MultipleQuery on all of the together) dapper has no problem mapping it to a given object.
What am I doing wrong?
1) Problem solved when I used the real models names instead of their interfaces names:
TopicView instead of ITopic, TopTopicsView instead of IMessage;
2) Once that was fixed and there was no longer "no splitOn" error, started another problem with the < int > casting in line:
TopicsCount = readDb.Read<int>().Single()
probably mysql doesnt return numbers back as ints?
I tried using decimal, object, dynamic, etc.. with no luck. Eventually fixed it by creating another Model with int property inside that has the same name as the database int parameter and now it works.
3) Here's the final working code:
using (var conn = new MySqlConnection(GetConnectionString()))
{
var parameters = context.MapEntity(query);
var multi = conn.QueryMultiple(storedProcedure, parameters, commandType: System.Data.CommandType.StoredProcedure);
var TopicsList = multi.Read<TopicView>().ToList();
var TopTopicsList = multi.Read<TopTopicsView>().ToList();
var result = multi.Read<HomeView>().Single();
result.TopicsList = TopicsList;
result.TopTopicsList = TopTopicsList;
return result;
}
I have a need where i want to get the count of deleted items and get change set/collection for items that are not deleted.
How can i achieve that ?
i am able to do it using the LINQJS, but was wondering if there is more proper way of doing it.
var countryType = manager.metadataStore.getEntityType("Country");
var countries = manager.getEntities(countryType);
var deletedCount = Enumerable.From(countries)
.Where(function (x) {
return x.entityAspect.entityState == "Deleted"
}).Count();
self.totalRows(self.totalServerRows() - deletedCount);
var queryResult = Enumerable.From(countries)
.OrderBy(function(x){ x.Country_Code })
.Where(function (x) {
return x.entityAspect.entityState != "Deleted"
})
.Skip(self.pageIndex() * self.pageSize())
.Take(self.pageSize())
.ToArray();
self.list(queryResult);
The EntityManager.getEntities call is overloaded (see: http://www.breezejs.com/sites/all/apidocs/classes/EntityManager.html#method_getEntities ) so that you can simply ask for those entities within the entityManager that are of specific types or in specified states. So for 'deleted, try this:
var deletedEntities = em.getEntities(null, [EntityState.Deleted]);
or if you wanted just the Added or Modified entities
var deletedEntities = em.getEntities(null, [EntityState.Added, EntityState.Modified]);
I hope this helps.