How can I output all the data from a column at once, without using (map) and (forEach)
Column
one
two
three
// one two three
You can use in your request attributes property. This gives you only one column
where:{
attributes:['columnName']
}
Related
im new to js, have two question about how to parse a csv, i have a simple csv with two column, column1:'user', column2:'amount'
how can i get one array with all the 'user' column value and one
array with all the 'amount' column value?
And can i loop trough the rows and use index to get the
value of the two column? something like csv['amount'][0] or csv[0][1] or something like this?
ty.
First, declare 2 arrays, one for user, one for amount.
And then read this post to know how to read a file line by line.
After that, read this post to know how to split a string with a comma separator.
Finally, use the array.push() method to push the data into an array.
I am using Neo4j along with the Javascript driver and I am attempting to create some nodes via a set of parameters, there are two types of records.
The first record
testObject = {
created: timeStamp,
uuid: uid,
finalScore: correctNum;
}
This is a central node around which I want to have lots of nodes which have the same structure (defined below).
The Second record
responseObject = {
response: finalAnswer,
responseTime: responsetime,
backgroundNoise: noise,
}
There are many of these records inside the parameters, each one has different values such as response value, response time and background nosie.
My Question
UNWIND $responses AS responseObject CREATE (t:Test) SET t = responseObject
What I would like to do is choose which record gets used when creating the nodes and SETTING the properties. According to the documentation of records
a record is a form of ordered map and, as such, contained values can be accessed by either positional index or textual key. Can this be done at the query level when using UNWIND? For instance responseObject[2] would use the third record instead of the first.
If you want to get just one element from a list, then use indexing, not UNWIND. With UNWIND, you'd be getting all the elements of the list.
For example, to create a node with only the third element of $responses:
CREATE (t:Test) SET t = $responses[2]
I'm working with DataTables and i'm trying to search a result in a table with a dropdown. But rather than searching one column, I need to search in two specific columns.
The below syntax works with a single column but how do i do it with multiple columns?
var table = $('#example1').DataTable();
$("#filter").on('change', function() {
table.column([4]).search($(this).val()).draw();
});
I tried doing this but when i use this code it only searches the result in the first column, E.g. 4th Column. and ignores the rest.
table.column([4,5]).search($(this).val()).draw();
What is the proper method for this?
Lets summarize all things here. It will help other people as well.
You can achieve this as follow:
table.column(4).search(this.value).column(5).search(this.value).draw();
It will perform search on 4 column (4 is index of column), after that it will filter data from 5 column against provided filter value and at the end it will draw the table.
One thing to keep in mind is that Filter is applied on both columns, so both columns must contains matching data.
Here is its filddle
This can be achieved by using fnMultiFilter as it documentation explains:
This plug-in adds to DataTables the ability to set multiple column filtering terms in a single call (particularly useful if using server-side processing). Used in combination with the column sName parameter, simply pass in an object with the key/value pair being the column you wish to search on, and the value you wish to search for.
Use columns() in place of column():
var table = $('#example1').DataTable();
$("#filter").on('change', function() {
table.columns([4,5]).search($(this).val()).draw();
});
From the doc, you should be using .columns() (note the plural)
For an OR search among multiple columns, disable columns for the search using
columns.searchableSince: Enable or disable search on the data in a certain column.
Alternatively, you can also use an HTML attribute to remove the column from the search
<th data-searchable=false>
I am new at pentaho, I am using a step „Merge rows (diff)“ and compare two tables. Problem ist that I dont know the key and value fields to compare of my origin tables, I can only read them in „Javascript“-step. Do you know any variants how to use such parameters in „Merge rows (diff)“-Step? Especially I am interested in „Values to compare“, because I need two compare all columns in these two tables and the structure of the tables (for example column names) can change in database any time, so I will have always different number of fields in „value to compare“.
Thank you for your help.
I'm using dgrid with the column reorder extension. I have two questions here -
I see that after reordering columns, the columns are present in the new order in the subRows attrinute of grid (note that I'm not referring to subRow here). Is that the best way to get the column order or are there any alternate/better ways to do it?
I understand that I will need to take care of saving the column order (or any other property for that matter) and restoring it. When I'm creating the grid with a saved order, what is the best way to do it? Should I create the columns in the saved order or can I create them in the standard order and then re-order them as per my saved order? If the latter is possible, how do I do it?
Thanks,
Yes, subRows is likely the most consistent way to get the column order.
Regarding saving/restoring, I could fathom doing something like the following. Note that for simplicity's sake, I'm making some assumptions here:
You only have a single sub-row (the same approach could be used for multiple, I figure, but you'd need outer loops)
Each column references a unique field
You are targeting only ES5+ environments (since I use ES5 Array methods below)
When saving the sub-rows, save just the field that each column references (which will make it trivial to serialize):
var persistedSubRow = grid.subRows[0].map(function (column) {
return column.field;
}
Then, when creating the grid, have an object hash of your columns in the default order (which you can use to set columns if there are no persisted settings), but if persisted settings exist, use that to determine the order by mapping it back against the hash:
var columns = {
field1: ...,
field2: ...,
...
}
if (persistedSubRow) {
persistedSubRow = persistedColumns.map(function (field) {
var column = columns[field];
// Normally when an object hash is specified for columns,
// field is autodetected from the key. Converting to array will
// lose that, so set it within the object.
column.field = field;
return column;
});
}
var grid = new Grid({
// grid.columns accepts either an object or array as input
columns: persistedSubRow || columns,
...
});
Let me know if you run into trouble; I'm shooting from the hip here, and haven't tested the above.