ng-grid column level filtering with substring search - ng-grid

I have looked at this plunker.
http://plnkr.co/edit/WJzTr8AR8dhWIjXELNY1?p=preview
It filters on first characters. Has anyone attempted to perform this filtering based on a substring search. If so please let me know
I worked on modifying the filter text as shown
angular.forEach(filterBarPlugin.scope.columns, function(col) {
if (col.visible && col.filterText) {
var filterText = (col.filterText.indexOf('*') == 0 ? col.filterText.replace('*', '') : col.filterText + "^") + ";";
searchQuery += col.displayName + ": " + filterText;
}
});

The original plunkr is design filtering from the beginning characters. If you went to filtering from the substring, you can try * begin filter textbox.
If you don't like it, you can modify filterBarPlugin function :
var filterText = (col.filterText.indexOf('*') == 0 ? col.filterText.replace('*', '') : "^" + col.filterText) + ";";
searchQuery += col.displayName + ": " + filterText;
To
var filterText = col.filterText +'; ';
searchQuery += col.displayName + ": " + filterText;
Example
updated: fixed not allow for multiple column sorting, thanks #mainguy

This is not really an answer but more an update to #allyusd's answer.
He is basically right, but his wildcardless solution does not allow for multi column sorting because a semicolon is missing.
With these small changes:
angular.forEach(filterBarPlugin.scope.columns, function(col) {
if (col.visible && col.filterText) {
var filterText = col.filterText +'; ';
searchQuery += col.displayName + ": " + filterText;
}
});
you can filter in this plunk for name=or AND age=4 and you will get Enors as result.
As I said: Just an update, kudos to allyusd!

Related

Getting empty value with dot walk for groupBy in GlideAggrigate

I need to get the value for classname in below case. I am getting empty value. Let me know what I am missing. I need to find all distinct classes for every type.
var ga_type = new GlideAggregate('cmdb_rel_ci');
ga_type.groupBy('type');
ga_type.query();
if(ga_type.next()){
gs.log("Type : " + ga_type.type.getValue());
var ga_parent = new GlideAggregate('cmdb_rel_ci');
ga_parent.addQuery('type.sys_id', ga_type.type.getValue());
ga_parent.groupBy('parent.sys_class_name');
ga_parent.query();
var parent = [];
while(ga_parent.next()){
var p = {};
p.parentClassName = ga_parent.parent.sys_class_name.toString();
p.parentName = ga_parent.parent.name.toString();
gs.log("ParentClassName : " + p.parentClassName + " Parent Name : " + p.parentName);
parent.push(p);
}
}
As Tim says it's hard to know exactly what's being asked here, but it looks like you might be trying to get a list of all the types of relationships in cmdb_rel_ci. If that's the case, this should do it:
var count = new GlideAggregate('cmdb_rel_ci');
count.addAggregate('COUNT', 'type');
count.query();
var listOfParents = [];
while(count.next()){
var parent = count.type;
var parentCount = count.getAggregate('COUNT','type');
listOfParents.push(parent); //or parent.getDisplayValue()
gs.log(parent.getDisplayValue() + ": " + parentCount);
}
This is basically just the third example from the docs: GlideAggregate

Cascading Select in Javascript and Telerik RadFormDecorator

I am trying very hard to make my cascading select decorate using telerik form decorator. Here is my js,
var attributes = s.attributes;
for (var i = 0, iLen = attributes.length; i < iLen ; i++) {
$elem.append('<option ' + (selectedValue === attributes[i].id ? 'selected ' : '') + 'value="' + attributes[i].id + '">' + attributes[i].name + '</option>');
}
after this I am calling,
formDecorator.decorate($elem[0], false);
It only works first time when the parent select changed(in a cascading select). But after this nothing works. I have tried,
formDecorator.decorate();
and
formDecorator.updateSelect($elem[0]);
Is there is any way to make it work?
A quick search in Telerik's forums gave me this thread that seems to have a useful response: http://www.telerik.com/community/forums/aspnet-ajax/form-decorator/cascading-select-in-javascrip-and-telerik-radformdecorator.aspx. I would give it a try and post there for more people to see. I hope it helps you.

JDBC ResultSet get column from different tables

i wan to retrieve data from query involving many tables.
i have a query as follows
String sql = "SELECT "
+ "s.Food_ID AS 'Sales_FoodID', "
+ "f.Food_Name AS 'foodName' "
+ "FROM Ordering o, Sales s, Food f"
+ " WHERE o.Table_No = " + tableNo + ""
+ " AND o.Paid = '" + NOT_PAID + "'"
+ " AND s.Order_ID = o.Order_ID"
+ " AND f.Food_ID = s.Food_ID;";
resultSet = statement.executeQuery(sql);
no error were found when i run the program, but after i add this line to get a table's column data:
String orderID = resultSet.getString("foodName");
i'm given this error:
java.sql.SQLException: Column not found
anyone know why?
You have to use next() method.
You should know that ResultSet is implicitly positioned on position before first row so you need to call next to get current position and if is valid, it returns true, else returns false (cursor is positioned after the last row).
rs = statement.executeQuery(sql);
while (rs.next()) {
String orderID = rs.getString(2);
}
Note: You can use also rs.getString(<columnName>) but in case when you know how your statement looks i recommend to you use index instead of columnName.
After calling the resultSet.executeQuery() you need to call the next() to pulling the records from db
after that you can call setXxx() provided by Java API

C# Convert a DataTable to List<string>

I have a 1 row DataTable that I'd like to convert to the following format:
Column1Name : value
Column2Name : value
Column3Name : value
etc...
How can this be accomplished with LINQ??
Thanks!
How about something like:
DataTable table = ...
// Overlays the columns over the only row's items
// and combines each column-item pair as required.
var items = table.Columns
.Cast<DataColumn>()
.Zip(table.AsEnumerable().Single().ItemArray,
(column, value) => column.ColumnName + " : " + value);
var result = string.Join(Environment.NewLine, items);
Here's another (IMO better) approach:
// Uses the DataRow's column-indexer to match a column with
// the corresponding row-item.
var items = from DataColumn column in table.Columns
select column.ColumnName + " : " + table.Rows[0][column];
var result = string.Join(Environment.NewLine, items);

XPath question multiple selects

var assets1 = data.SelectNodes("//asset[#id]=" + oldBinaryAssetId);
var assets2 = data.SelectNodes("//Asset[#id]=" + oldBinaryAssetId);
Is it possible to make 1 xpath query of the two above?
Your XPath is wrong to be gin with. You probably mean:
data.SelectNodes("//Asset[#id = '" + oldBinaryAssetId + "']");
To combine both variants (upper- and lower-case), you could use:
data.SelectNodes("//*[(name() = 'Asset' or name() = 'asset') and #id = '" + oldBinaryAssetId + "']");
or
data.SelectNodes("(//Asset | //asset)[#id = '" + oldBinaryAssetId + "']");
If you have any way to avoid the // operator, I recommend doing so. Your queries will be faster when you do, though this might only be noticable with large input documents.

Resources