Kendo Grid (Java Script) : Multiple columns each column from a record from DB with inline batch Edit/Update? - kendo-grid

What I want: Columns with Weekdays in Kendo grid where each column may or may not coming from DB. Also, batch edit/Update functionality. Is this feasible somehow if so any help will be appreciated to get me started else any other suggestion, please?
In DB:
Date | in | out | User ID
5/1/2017 | datetime | datetime | int
5/3/2017 | datetime | datetime | int
5/5/2017 | datetime | datetime | int
Output:
User Name | 5/1/2017 | 5/2/2017 | 5/3/2017 | 5/4/2017 | 5/5/2017
Where cell for [5/1/2017], [5/3/2017] and [5/5/2017] will be editable.

It is possible to define the grid column schema dynamically where:
for (var i = 0; i < 5; i++) {
var entryIndex = "entries[" + i + "]";
columns.push({
field: entryIndex,
title: "Column " + i
});
}
would become something like:
// first column for username
columns.push({ field: valuesFromDatabase.UserName });
// loop to append each available date in the list as a column
for (var i = 0; i < valuesFromDatabase.Dates; i++) {
columns.push({
field: i.NumberOfVisits,
title: i.Date
});
}
valuesFromDatabase being a list of objects holding your data (Dates containing a list of whatever content you wish to show in the associated column, in this example a number of visits). I haven't got a chance to test this but it should get you on the right track.
A few other examples of dynamically creating columns:
JSFiddle with editable grid
Example using Razor

Related

Checking discord messages with sql

So I've been trying to check each message from a sql table. My sql table structure is down below:
Example:
| id | | triggervalue | | triggermessage |
| 633666515413237791 | | hello, world, test | | Trigger works! |
(array like string is something like: hello, world, test)
I want to check each message from each triggervalue column to see if message contains a string from array like string.
Here is what I've done:
I tried to merge every single array like string then send(triggermessage) where the same row of the found array contains, then checking for word.
connection.query(`SELECT * FROM triggervalue`, (err, rows) => {
let array = []
for(i = 0; i < rows.length; i++) {
let received = rows[i].jsonstring;
var intarray = received.replace(/^\[|\]$/g, "").split(", ");
array.concat(intarray)
// continue code here...
}
})
However, I can't get the triggermessage of the same row of found array. How would I go for it? I've been stuck here for quite a while... Sorry if this way of asking is wrong, thanks!
(Sorry if my english is bad)

SQLAlchemy - filtering rows before today with autoloaded DATETIME column?

I have a MARIADB database radio_progs with a table FUTUREEPISODE. I'm using SQLAlchemy and trying to add a function that selects all entries in the table that are before today.
I'm having problems with the datetime field though. Is this as I'm autoloading the fields? In my real world example I have a number of columns so would prefer to autoload than specify each individually.
error is
eps = self.query.filter_by(IN_LIST=1, EP_ENDTIME < todays_datetime).all()
^
SyntaxError: positional argument follows keyword argument
The table has the following columns
| Column | Type |
| ---------- | ---------- |
| ID | int(11) |
| EP_ENDTIME | datetime |
| IN_LIST | tinyint(1) |
from datetime import datetime
from sqlalchemy import and_, func
from .dbmgr import db
class FutureEpisode(db.Model):
__bind_key__ = 'radio_progs'
__tablename__ = 'FUTUREEPISODE'
__table_args__ = {
'autoload': True,
'autoload_with': db.engine
}
def get_expired(self):
todays_datetime = datetime(datetime.today().year, datetime.today().month, datetime.today().day)
eps = self.query.filter_by(IN_LIST=1, EP_ENDTIME < todays_datetime).all()
return eps
Using filter rather than filter_by works, i.e. changing the query to:
eps = self.query.filter(FutureEpisode.IN_LIST==1, FutureEpisode.EP_ENDTIME < todays_datetime).all()

Storetext from a table choice correct lines to store for Selenium Ide Ui Vision Kantu

I need to storetext all lines from a table where CODICE CATASTALE have a value
I add an image to show, I need to save all line in variable with storetext with this characteristic CODICE CATASTALE have a value, in the image I add 1 - 2 - 3 - 4 to explain line to store.
This is a relative storetext when CODICE CATASTALE have a value stored the line.
Here the page
nonsolocap.it/cap?k=56040
Image
After the execution such script in Selenium IDE table variable will contain data from the table. xpath_to_all_rows_with_CODICE_CATASTALE should be replaced with corresponding xpath.
store xpath count | xpath = xpath_to_all_rows_with_CODICE_CATASTALE | n
store | 0 | j
while | ${j} < ${n} |
store | | rowElement
store | 0 | i
while | ${i} < 7 |
store text | xpath = xpath_to_all_rows_with_CODICE_CATASTALE[${j}]/td[${i}] | element
execute script | if (${i} != 0) var arr = ${rowElement}; else var arr = []; var element = ${element}; arr.push(element); return arr; | rowElement
execute script | return Number(${i}) + 1; | i
end| |
execute script | if (${j} != 0) var arr = ${table}; else var arr = []; var rowElement = ${rowElement}; arr.push(rowElement); return arr; | table
execute script | return Number(${j}) + 1; | j
end| |
use scvSave command and give a name for the target for divide raws

Copy previous values kettle pentaho

I have an issue and i'm looping on it! :| I hope someone can help me..
So i have an input file (.xls), that is simple but there are a row (lets say its "ROW1") that is like this:
ROW1 | ROW2 | ROW3 | ROW_N
765 | 1 | AAAA-MM-DD | ...
null | 1 | AAAA-MM-DD | ...
null | 1 | AAAA-MM-DD | ...
944 | 2 | AAAA-MM-DD | ...
null | 2 | AAAA-MM-DD | ...
088 | 7 | AAAA-MM-DD | ...
555 | 2 | AAAA-MM-DD | ...
null | 2 | AAAA-MM-DD | ...
There are no stardard here, like you can see.. There are some lines null (ROW1) and in ROW2, there are equal numbers, with different association to ROW1 (like in line 5 and 6, then in line 8 and 9).
My objective is to copy and paste the values from ROW1, in the ROW1 after when is null, till isn't null. Basically is to copy form previous step, when is null...
I'm trying to use the "Formula" step, by using something like:
=IF(AND(ISBLANK([ROW1]);NOT(ISBLANK([ROW2]));ROW_n=ROW1;IF(AND(NOT(ISBLANK([ROW1]));NOT(ISBLANK([ROW2]));ROW_n=ROW1;ROW_n=""));
But nothing yet..
I've tried "Analytic Query" but nothing too..
I'm using just stream a xls file input..
Tks very much, any help is very much appreciiated!!
Best Regardsd!
Well i discover a solution, adding a "User Defined Java Class" with the code below:
import java.util.HashMap;
private FieldHelper output_field, card_field;
private RowSet out, log;
private String previou_card =null;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
if (first)
{
first = false;
out = findTargetRowSet("out");
output_field = get(Fields.Out, "previous_card");
} else {
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
r = createOutputRow(r, data.outputRowMeta.size());
if (previous_card != null) {
output_field.setValue(r, previous_card);
}
if (card_field == null) {
card_field = get(Fields.In, "Grupo de Cartões");
}
String card = card_field.getString(r);
if (card != null && !card.isEmpty()) {
previous_card = card;
}
// Send the row on to the next step.
putRowTo(data.outputRowMeta, r, out);
}
return true;
After this i have to put a few steps but this help very much.
Thank you mates!!
Finally i got result. Please follow below steps
Below image is full transformation screen.
Data Grid Data will be like these. Sorry for that in my local i don't have Microsoft because of that i took Data Grid. Instead of Data Grid you can drag and drop Microsoft Excel Input step.
Drag and Drop one java script step and write below code.
Last step of transformation, drag and drop Select values step and select the columns.( These step is no necessary)
Final result will be like these.
Hope this helps.

This query in Linq to Sql

i have in my DB table TBus fields like s1,s2.s3.s4,...sn
i get the seatNumber as a parameter and want to get that field just like i have it in my code.
Any idea please.
private string checkSeatValue(int busTripId, int seatNumber)
{
string sNumber = "s" + seatNumber.ToString();
// Some code here
string sqlCommand = "SELECT " + sNumber + " FROM TBus WHERE Id=" + busTripId + "";
// More code here
}
If you want pure Linq2SQL code, you should get the TBus object:
var bus = yourDataContext.GetTable<TBus>().Where(bus => bus.BusTripId == busTripId).SingleOrDefault();
And then switch your seat variable to get the desired field:
var seat;
switch(seatNumber)
{
case "s1":
seat = bus.Seat1;
break;
case "s2":
seat = bus.Seat2;
break;
// And so it goes on...
}
However, you can do pure SQL code via Linq also or play with reflection.
-- EDIT
As I said in the comment, I believe your database model can be improved. My advice would be having two tables:
TBus Table
TBusId - int [PK]
...
TBusSeat Table
TBusSeatId - int [PK]
TBusIs - int [FK referencing TBus.TBusId]
SeatNumber - int
...
That way, you have more natural flexibility to deal with those king of situations. Consider the following set of data:
TBus Table
TBusId
------
1
2
TBusSeat Table
TBusSeatId | TBusId | SeatNumber | PassengerName
------------------------------------------------
1 1 1 Josh Doe
2 1 2 John Doe
3 1 3 Jane Doe
4 2 1 Jack Doe
So, to deal with your desired query with Linq2SQL, it would be simple as this:
var seat = yourDataContext.GetTable<TBusSeat>().Where(seat => seat.TBusId == 1 && seat.SeatNumber == 2).SingleOrDefault();
And calling seat.PassengerName would result in John Doe.