DT::datatable selecting a row + creating sentences based on data - r

I'm trying to use datatable function with DT, and below is what I have so far:
datatable(pr, rownames=FALSE, colnames=c('Percentile Rank','Grade','From','To'),
filter='top', option = list(pageLength=5, autoWidth=TRUE),
caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',
'Note: ', htmltools::em('___caption')
))
Instead of using the caption, I want it available for the users to select a specific row to have the description (i.e., "A did better than ____ % of their peers in grade ___.") depending on the row they select.
How can I add a checkbox or make it possible for the users to select a specific row to get the description?
How can I include a sentence created based on the data (e.g., using paste)?

Related

Using a hashtable to fill textbox in poweshell

I created some Hash tables that will be used to fill text boxes. I want to access the Hash table with a variable that was selected from a list box.
$Dallas =#{
Address = "I20"
City = "Dallas"
State = "TX"
Zip = "75300"
}
I have a combo box with a list of city's
$myCity = $comboCity.Text
write-host $myCity "shows the city you selected"
I know that "$Dallas.Address" will show 120 but "$myCity.Address" is not a valid choice
My question is how do I make "$myCity" equal to the Hash table $Dallas?

Powerapps: Patch a record based on a text input control

I am wrestling with a simple patch function to update a record based off the value of an text input control. What I want is for PowerApps to update a record where a value in a table = the value in a text input field.
Table2 contains my data.
ID is unique for each row.
ProjID is the name of the text input control. This contains the value of ID that I want to update.
Current Phase is the column I want to update with the value in projID.
I have based the code below off some code which I use to create new records which works, so I think it is the lookup element that is not working.
Patch(
Table2,
lookup(Table2,Id = ProjID.Text ),
{
'Current Phase': CurrentPhase.Text,
}
)
)
Any help would be greatly appreciated!
The below should work and you can use comma either to add more conditions or data values
Patch( Table2,
First(Filter(Table2, ProjID.Text = Id ) )
, {
'Current Phase': CurrentPhase.Text
}
)

PeopleSoftModifying field labels while keeping the column label

I have a grid where one column is a column of hyperlinks. How can I set the field labels to display the field's value, while keeping the column's label fixed?
You do this in two steps
set the Grid Column Label
For each row in the grid assign a value to the label of the field associated with the button
Ensure on the page that you have set the page field value for the grid and for the hyperlink column
The example below assumes the field associated with the hyperlink is SELECT_BTN. The column heading will be set to "My Column Title" and the hyperlink on the button will be set to the value of the DESCR field on same record.
Local Grid &grid;
Local GridColumn &hyperlinkColumn;
Local integer &i;
Local Rowset &rowset;
/* set the column header */
&grid = GetGrid(%Page, "MYRECORD");
&hyperlinkColumn = &grid.GetColumn("SELECT_BTN");
&hyperlinkColumn.Label = "My Column Title";
&rowset = GetLevel0()(1).GetRowset(Scroll.SOMERECORD);
/* Set the value for each hyperlink in the rowset */
For &i = 1 To &rowset.ActiveRowCount
&rowset(&i).SOMERECORD.SELECT_BTN.Label = &rowset(&i).SOMERECORD.DESCR.Value;
End-For;

how to sanitize data in sqlite3 column

I have a sqlite3 table with a column by the name Title, which stores the names of the some movies.
Table name - table1
Column name - Title
Examples data: "Casablanca" (1983) {The Cashier and the Belly Dancer (#1.4)}
I have another sqlite3 table with a column that stores movie titles.
Table name - table2
Column name - Title
Examples data: casa blanca
Both these tables were created using different datasets, and as such although the movie name is the same (casa blanca vs "Casablanca" (1983) {The Cashier and the Belly Dancer (#1.4)}), both are stored with extra text.
What i would like to do is to SANITIZE the already stored data in both the columns. By sanitization, I would like to strip the cell content of:
1. spaces
2. spl chars like !, ', ", comma, etc..
3. convert all to lower case
I hope with that atleast some level of matching can be had between both the columns.
My question is, how do i perform these sanitizations on data that is already stored in sqlite tables. I do not have an option to sanitize before loading, as i only have access to the loaded database.
I am using sqlite 3.7.13, and i am using sqlite manager as the gui.
Thank You.
This task is too specialized to be done in SQL only.
You should write simple Perl or Python script which will scan your table, read data row by row, scrub it to meet your requirements and write it back.
This is example in Perl:
use DBI;
my $dbh = DBI->connect("dbi:mysql:database=my.db");
# replace rowid with your primary key, but it should work as is:
my $sth = $dbh->prepare(qq{
SELECT rowid,*
FROM table1
});
while (my $row = $sth->fetchrow_hashref()) {
my $rowid = $row->{rowid};
my $title = $row->{title};
# sanitize title:
$title = lc($title); # convert to lowercase
$title =~ s/,//g; # remove commas
# do more sanitization as you wish
# ...
# write it back to database:
$dbh->do(
qq{
UPDATE table1
SET title = ?
WHERE rowid = ?
}, undef,
$title,
$rowid,
);
}
$sth->finish();
$dbh->disconnect();

Edit the code of a GridView column asp.net

I've been looking for a way to control the text that appears in a particular column of a GridView.
For example consider a database with two tables Student and Class.
I want to add a column to the GridView which print out all the students in the Database, the column will show the student's class name, how can do it? (I can normally print the ClassId since its a FK in the student table)
I want to add a column to the GridView which print all the classes, the column will count the number of students in each class, how can I do it?
1- You can do that simply with inner join or a stored procedure to get the class name beside all the data you need in your query.
2- More than one way to do what you want:
For example:
you can add a column to your data table (empty column ), and fill it later through using Sum() aggregate function in a query.
DataTable result_dt = DAL_Helper.Return_DataTable(sqlSelect);//your original query
result_dt.Columns.Add("NumberOfStudent");
result_dt.Columns["NumberOfStudent"].DataType = typeof(string);
result_dt.Columns["NumberOfStudent"].MaxLength = 255;
if (result_dt.Rows.Count > 0)
{
for (int i = 0; i < result_dt.Rows.Count; i++)
{
//Here u can fill your new empty column.
}
}
result_dt.AcceptChanges();
After you return your customized data table(as a data source), you can bind it to the grid view.
Another solution : add an empty column to the grid view and in the RowDataBound event of the grid view you can fill this column through some loop and you can use LINQ to help you in getting the summation.

Resources