I have an HTML table of Input elements. How do I submit just the rows with edited fields to the server?
| 1 | A | B | C | D | E |
| 2 | A | B | C | D | E |
| 3 | A | B | C | D | E |
If 2B is changed, I want to send row 2.
create dynamically the inputs, add a event listener to each one (onchange) to add the input to an array, on other event get the data of the inputs in the array, send it and clean the array
Related
My dexiedb structure looks like below.
const db = new Dexie('shipment-execution');
db.version(1).stores({
root: '++id,shipmentid,stopid',
})
My IndexedDB will look like below
| id| shipmentid| stopid|
| 1 | 6000001 | 10 |
| 2 | 6000001 | 20 |
| 3 | 6000001 | 30 |
| 4 | 6000002 | 10 |
| 5 | 6000002 | 20 |
I am trying to get all the data which has shipmentid equal to 6000001. Each time it is returning only one record (the first record ).
db.root.where({shipmentid : '6000001'}).toArray().then((d)=>{
console.log(d);
})
output is only fetching the first record
| id| shipmentid| stopid|
| 1| 6000001 | 10 |
Please let me know, what I am doing wrong.
I have the following table:
+----------+----------+---------+----------+----------+----------+
| Date | A | B | C | P | D |
+----------+----------+---------+----------+----------+----------+
|2019-01-10| -111,000 | 666,000 | 78,000 | 45 | 120,000 |
|2019-01-09| 555,000 | 55,000 | 100,000 | 55 | 700,000 |
|2019-01-08| 48,000 | 30,000 | 40,000 | 65 | 450,000 |
|2019-01-07| 600,000 |-450,000 | -800,000 | 90 | 980,000 |
+----------+----------+---------+----------+----------+----------+
May I know how to create a temporary table from the existing table above to become the table as below:
+----------+----------+---------+----------+----------+
| Date |Components| Values | Comp_no | P |
+----------+----------+---------+----------+----------+
|2019-01-10| A |-111,000 | 1 | 45 |
|2019-01-10| B | 666,000 | 2 | 45 |
|2019-01-10| C | 78,000 | 3 | 45 |
+----------+----------+---------+----------+----------+
Then sort it according to absolute values as below:
Give numbers to the largest value as '1', 2nd largest as '2' and so on.
The sorted_comp_no represents the order whereby the components is sorted where '1' is 'B', '2' is A and '3' is C.
+----------+----------+---------+----------+----------+--------------+
| Date |Components| Values | comp_no | P | sort_sequence|
+----------+----------+---------+----------+----------+--------------+
|2019-01-10| A |-111,000 | 1 | 45 | 2 |
|2019-01-10| B | 666,000 | 2 | 45 | 1 |
|2019-01-10| C | 78,000 | 3 | 45 | 3 |
+----------+----------+---------+----------+----------+--------------+
Use the comp_no and sort.
The components are now sorted according to their values.
+----------+----------+---------+----------+----------+--------------+
| Date |Components| Values | comp_no | P |sorted_comp_no|
+----------+----------+---------+----------+----------+--------------+
|2019-01-10| B | 666,000 | 2 | 45 | 2 |
|2019-01-10| A |-111,000 | 1 | 45 | 1 |
|2019-01-10| C | 78,000 | 3 | 45 | 3 |
+----------+----------+---------+----------+----------+--------------+
I've already created the temporary table template but still stuck in taking the name of specific column only (A,B and C) to be put into a column of its own category ignoring column D . Column P is brought into the temporary table but remain as is. There is also a dependency to the date column as there are multiple data of different date.
But the end goal is to be able to "sort specific column according to its absolute value at a specific date dynamically".
I have a tables filled with data using Jquery Datatables, what i want is to be able to sum all data from the distinc values of a column but when a dropdownlist value is changed and save the sum value into a new Html Input with Javascript Example:
I got my table filled with data like this:
|Platillo | PDV | Precio | Can | Date |
------------------------------------------------------------------
| Poz | REST | 40 | 2 | 01/02/2016|
------------------------------------------------------------------
| Tor | REST | 50 | 2 | 02/02/2016|
------------------------------------------------------------------
| Zes | REST | 100 | 2 | 01/02/2016|
------------------------------------------------------------------
| Poz | FUEM | 60 | 2 | 01/02/2016|
------------------------------------------------------------------
| Tor | FUEM | 70 | 2 | 01/02/2016|
------------------------------------------------------------------
| Zes | FUEM | 120 | 2 | 01/02/2016|
------------------------------------------------------------------
| Poz | VTSI | 45 | 2 | 02/02/2016|
------------------------------------------------------------------
| Tor | VTSI | 57 | 2 | 01/02/2016|
------------------------------------------------------------------
| Zes | VTSI | 10 | 2 | 02/02/2016|
------------------------------------------------------------------
i want is to be able to sum all the values from the column 'Precio' into a 'Html Input Field' but i want to sum the totals of each distinct value from column 'PDV', and triggered by the value of a dropdown list,
Ex: if user select's Date '01/02/2016' i shoul fil my html Inputs with the sum of the data of all distinct value of column 'PDV' but only when they match the Date selected by the user '01/02/2016' looking for this output:
<option value="">Todos</option>
<option value="01/02/2016">#item</option> // USER SELECTS THIS VALUE
<option value="02/02/2016">#item</option>
My input field are like follow:
<input value="//TOTAL SUM FROM REST WHERE DATE IS EQUAL AS UsER SELECT '01/02/2016'" />
<input value="//TOTAL SUM FROM REST WHERE DATE IS EQUAL AS UsER SELECT '01/02/2016'" />
<input value="//TOTAL SUM FROM REST WHERE DATE IS EQUAL AS UsER SELECT '01/02/2016'" />
Im new to javascript and right now i have only be able to filter my Datatable based on the selected date but i need to sum all distincs values of my 'PDV' column each time user selects a date value how can i do it?
UPDATED:
i have the code of my dropdown filter y just need to know how to sum columns based on unique column items on my search javascript
This is my search code:
$('#sel0').on('change', function () {
dataTable.columns('.fechas').search(this.value).draw();
var datafecha = $(this).val();
});
You need to write a custom filter. Or take a look at this below to get an idea :
var val = $.fn.dataTable.util.escapeRegex($('dropdown').val());
column.search( val ? '^'+val+'$' : '', true, false ).draw();
var sum = column.data().unique().sum();
alert(sum);
I have a handsontable, for example:
+---+------+-------+-------+
| | A | B | C |
+---+------+-------+-------+
| 1 | 10 | 20 | 30 |
+---+------+-------+-------+
| 2 | 5 |=0.5+A3|=0.5+B3|
+---+------+-------+-------+
| 3 |=A1+A2|=B1+B2 |=C1+C2 |
+---+------+-------+-------+
when the table is loaded, B2 and C2 has value of #NEED_UPDATE instead of calculation result of its formula. how to handle this issue?
Nevermind, I solved this. add afterRender callback:
afterRender: function(){
this.setDataAtCell(ROW, COL, FORMULA);
}
this will automatically update all cell to the right.
I have a working event tracker that writes every event in a mysql table.
Table
id date userid event
5100 2014-03-25 14:18:55 user333 AI
5101 2014-03-25 14:19:02 user333 Click
5102 2014-03-25 14:19:02 user333 Click
...
Thats works so far very good. But now, I want to write a little report tool in node.js
I try to get the values with this SQL Query:
SELECT DATE_FORMAT(date,"%Y%m%d") AS date, event, count(*) AS count FROM databasetest WHERE date>="'+ daystartdate +'" AND date<="'+ dayenddate +'" GROUP BY YEAR(date), MONTH(date), DAY(date), event
Giving me this:
+----------+----------+-------+
| date | event | count |
+----------+----------+-------+
| 20140320 | AI | 6 |
| 20140320 | Click | 2 |
| 20140320 | swipe | 2 |
| 20140321 | Click | 6 |
| 20140321 | error | 5 |
| 20140321 | swipe | 2 |
| 20140321 | touch | 3 |
| 20140322 | AI | 3 |
| 20140322 | Click | 3 |
| 20140322 | error | 1 |
| 20140322 | mapsload | 3 |
| 20140322 | touch | 1 |
| 20140323 | AI | 2 |
| 20140323 | Click | 2 |
| 20140323 | touch | 5 |
| 20140324 | AI | 3 |
| 20140324 | Click | 1 |
| 20140325 | AI | 25 |
| 20140325 | Click | 48 |
| 20140325 | error | 16 |
| 20140325 | mapsload | 7 |
| 20140325 | swipe | 15 |
| 20140325 | touch | 32 |
+----------+----------+-------+
But I need the data in this form:
+----------+----------+-------+-----
| date | Click | AI | ....
+----------+----------+-------+-----
| 20140320 | 0 | 6 |
| 20140321 | 2 | 2 |
| 20140321 | 2 | 5 |
Is this possible with a SQL query or do I need to loop through the results in my javascript code. I tried many possible solution but didnt get it to work.
Thank you.
This is a very common question, keywords to search are "transpose" and "pivot". To save you the trouble, this is something that MySQL is not able to do. SQL Server (a MS product) can do this, though.
You will need to loop through the output and build the result set yourself.
var results = []
data.forEach(function(row, rowidx) {
results[row.date] = results[row.date] || {};
results[row.date][row.event] = results[row.date][row.event] || 0;
results[row.date][row.event] += row.count;
});