how to get all values from dataview in a webix,
this still doesn't work by me, because the table is not to be selected
var data = $$('experienceTable');
console.log(data.getSelectedId())
To get some specific record
console.log(data.getItem(id));
And to get all records
console.log(data.serialize())
Related
I have a data table that has a hidden column. I want to set the values of that column to a java script array. (Note: I want to get the values that belong to the current page only). If I use a search filter, I want the values of the current page of the search result.
I've tried like this.
$('#datatbl').DataTable().rows({filter: 'applied'}).every(function () {
var row = this.data();
arr.push(row[0]);
});
But,this code gives all values from all the pages. Please help....
Try adding page:'current' in selector.
$('#datatbl').DataTable().rows({filter: 'applied', page:'current'})
I'm trying to update a single row,
using this query,
$update_row = PayRecord::where('date_from',$date_from)
->where->('date_to',$date_to)
->update(['status',1]);
what I want to do is to get the id of the updated row, without creating another query to get the id,
$get_updated_row_id = PayRecord::where('date_from',$date_from)
->where->('date_to',$date_to)'
->get('id');
Thank You,
Remove extra -> from where clause.
This may useful to you.
$update_row = PayRecord::where('date_from',$date_from)
->where('date_to',$date_to)
->first();
$update_row->update(['status',1]);
$update_row->id; // to get the id
How can I append a table with D3.js only if this table doesn't already exist?
E.g. I want to append several tables to a DIV, so if a table with id='table1' has already been appended, in case it appears again in my list with updates, I would like it to be updated but not appended again as a second table.
What I do so far is:
var tableDiv = d3.select( '#tablesContainer' ).append('table').attr('id', 'table1');
however in case I try to append a second table with same id, id=table1, it will create a new DOM element with that same id.
Any help is very much apreciated.
To update already existing Dom elements, you want to select, and then manipulate them like so:
var table = d3.select('#tablesContainer').select('#table1');
and do something to the table, e.g.
table.style("backgroundColor", "grey");
You are using an append, where you should be using select.
In case you were planning on creating the tables based on data, use the update Selection:
var tables = d3.select('#tablesContainer').data(data).style("backgroundColor", "grey");
To enter and update in two lines of code:
d3.select('#tablesContainer').data(data);
tables.enter().append("table").merge(tables).style("backgroundColor", "grey");
I have a dataset (called dataSet below) with a single table and some records in it. One of the columns is called Message and contains an error message. If any records have a value in this field I want to copy it into an error dataset (errorDataSet below) and then remove it from the original dataset. I managed to get this far with LINQ:
DataSet errorDataSet = dataSet.Copy();
//find all records that have a Message column value
var query = from row in errorDataSet.Tables[0].AsEnumerable()
where !String.IsNullOrEmpty(row.Field<string>("Message"))
select row;
DataSet tempErrorDataSet = errorDataSet.Clone();
foreach (var row in query)
{
tempErrorDataSet.Tables[0].Clear();
tempErrorDataSet.Tables[0].ImportRow(row);
utility.WriteError(connectorName, row["Message"].ToString(), tempErrorDataSet);
//remove the error row from the good data
dataSet.Tables[0].Rows.Remove(row);
}
The bottom line throws an exception or I get errors regarding modifying a collection etc. I'm sure there is a simple way of doing this in LINQ.
Note: The reason I have tempErrorDataSet is that I convert it to XML and pass it into a stored proc - it only takes a record at a time in that format, hence I clear it each time.
Your query is enumerating (indirectly) through the rows in the table. As you should already know, you cannot modify a collection (remove something in this case) as you enumerate over it. Throw the contents into a list beforehand. That way you're not enumerating through the actual table but a copy of some rows.
var query = (from row in errorDataSet.Tables[0].AsEnumerable()
where !String.IsNullOrEmpty(row.Field<string>("Message"))
select row).ToList();
In the table ReservationWorkerPeriods there are records of all workers that are planned to work on a given period on any possible machine.
The additional table WorkerOnMachineOnConstructionSite contains columns workerId, MachineId and ConstructionSiteId.
From the table ReservationWorkerPeriods I would like to retrieve just workers who work on selected machine.
In order to retrieve just relevant records from WorkerOnMachineOnConstructionSite table I have written the following code:
var relevantWorkerOnMachineOnConstructionSite = (from cswm in currentConstructionSiteSchedule.ContrustionSiteWorkerOnMachine
where cswm.MachineId == machineId
select cswm).ToList();
workerOnMachineOnConstructionSite = relevantWorkerOnMachineOnConstructionSite as List<ContrustionSiteWorkerOnMachine>;
These records are also used in the application so I don't want to bypass the above code even if is possible to directly retrieve just workerPeriods for workers who work on selected machine. Anyway I haven't figured out how it is possible to retrieve the relevant workerPeriods once we know which userIDs are relevant.
I have tried the following code:
var userIDs = from w in workerOnMachineOnConstructionSite select new {w.WorkerId};
List<ReservationWorkerPeriods> workerPeriods = currentConstructionSiteSchedule.ReservationWorkerPeriods.ToList();
allocatedWorkers = workerPeriods.Where(wp => userIDs.Contains(wp.WorkerId));
but it seems to be incorrect and don't know how to fix it. Does anyone know what is the problem and how it is possible to retrieve just records which contain userIDs from the list?
Currently, you are constructing an anonymous object on the fly, with one property. You'll want to grab the id directly with (note the missing curly braces):
var userIDs = from w in workerOnMachineOnConstructionSite select w.WorkerId;
Also, in such cases, don't call ToList on it - the variable userIDs just contains the query, not the result. If you use that variable in a further query, the provider can translate it to a single sql query.