MaterialUI Table rows with different amount of cells aligned - material-ui

I am trying to create a table where I essentially have two headings of different cell size and the items in the table must follow the second heading, like this:
**Main Heading 1** | **Main Heading 2**
sub 11 | sub 12 | sub 13 | sub 14 | sub 21 | sub 22 | sub 23 | sub 24
item | item | item | item | item | item | item | item
...
I have tried with the following structure
<Table size="small" aria-label="stock-flow">
<TableHead>
<TableRow>
<TableCell>Main Heading 1</TableCell>
<TableCell>Main Heading 2</TableCell>
</TableRow>
<TableRow>
<TableCell>Sub 11</TableCell>
<TableCell>Sub 12</TableCell>
<TableCell>Sub 13</TableCell>
<TableCell>Sub 14</TableCell>
<TableCell>Sub 21</TableCell>
<TableCell>Sub 22</TableCell>
<TableCell>Sub 23</TableCell>
<TableCell>Sub 24</TableCell>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<TableCell>Item 11</TableCell>
<TableCell>Item 12</TableCell>
<TableCell>Item 13</TableCell>
<TableCell>Item 14</TableCell>
<TableCell>Item 21</TableCell>
<TableCell>Item 22</TableCell>
<TableCell>Item 23</TableCell>
<TableCell>Item 24</TableCell>
</TableRow>
</TableBody>
</Table>
But that aligns Main heading 1 and Main Heading 2 above sub11 and sub12 and leaves 6 empty spaces after that.
I essentially want to have 2 "main" columns and a way to create whatever sizes of columns/rows I want in each of them.
EDIT: I found the answer, I have to use the colSpan property and give it a value of the amount of cells that I want to have underneath the main heading, so both headings get colSpan={4}

I found the answer, I have to use the colSpan property and give it a value of the amount of cells that I want to have underneath the main heading, so both headings get colSpan={4}

Related

DokuWiki: Side-By-Side diff: Table with two cols in code block in table cell

I want to create a table in DokuWiki which has two rows.
On the left side is a code block (old code), and on the right side there is an other code block (new code).
How to format this in dokuwiki?
If it would be html, it would be easy:
<table>
<tr>
<td>
<pre>
...
</pre>
</td>
<td>
<pre>
...
</pre>
</td>
</tr>
</table>
Optional: Syntax highlighting for Python would be nice.
This should do the work:
| <code>Row 1 Col 1</code> | <code>Row 1 Col 2</code> |
Or for a simple monospaced text use '':
| ''%%Row 1 Col 1%%'' | ''%%Row 1 Col 2%%'' |
EDIT Add %% %% makes string to be not interpreted as DokuWiki syntax.
Here the documentation: https://www.dokuwiki.org/wiki:syntax
||border=1
||!Table heading 1||!Table heading 2||
||Cell 1.1||Cell 1.2||
||Cell 2.1||Cell 2.2||

use strings in PostgreSQL as variables to find column names

I have two tables where I want to join them and do a look up from one to find the column heading in another.
One table looks like this:
table: student_score
student| red |blue |green
------- -------- ------- -----
201 | 88 |89 |78
345 | 67 |72 |95
987 | 75 |81 |89
The other is like this:
table: student_history
student | color_last_year
------- -----------------
201 | red
345 | blue
987 | green
I'm looking to create a query in PostgreSQL that will allow me to pick last year's color (from the history table) as the column heading from the score table. In the past I've used javascript to do this, but would prefer to do it all in one psql query.
The js looked something like this:
function lastYear(color){
var query = 'SELECT student_score.' + color + '
FROM student_score
JOIN student_score ON student_score.student =
student_history.student
//...more code .... //;'
}
I've been trying to find help around this in documentation and searches, but not sure how best to set up my query.
You can use a case expression:
select
s.student,
case h.color_last_year
when 'red' then s.red
when 'blue' then s.blue
when 'green' then s.green
end as val
from student_score s
join student_history h on s.student = h.student;

NHibernate inserting wrong Id

I am using MVC razor 5
I'm making managment page to add SelectList values (like Car models)
I have values in my car models table:
--------------------------------------
Id | Name | Deleted
1 | BMW | False
2 | Audi | False
3 | Ford | False
4 | BMW5 | False
5 | SEAT | False
--------------------------------------
When i add new value id becomes 130++
I have noticed that my main class last records Id is 130.
And when I insert a record in car model class Id is the nextval(Id) of main class
But these two tables does not share same Controller or so...
All sessions are closed by transaction.Commit() so session closes.
What may be wrong?
Nhibernate class mapping:
<class name="web_nt.Models.Class.CarModel" table="car_model" schema="public">
<id name="Id" column="id" type="int">
<generator class="native" />
</id>
<property name="model_name" />
<property name="deleted" />
</class>
It was generator class fault.
To use postgres sequence I needed to specify it (NHibernate does not always catch it itself)
<generator class="sequence">
<param name="sequence">car_model_id_sequence</param>
</generator>

How do you exclude a column from showing up if there is no value?

Question about a query I'm trying to write in SQL Server Management Studio 2008. I am pulling 2 rows. The first row being the header information, the second row being the information for a certain Line Item. Keep in mind, the actual header information reads as "Column 0, 1, 2, 3, 4,.... etc."
The data looks something like this:
ROW 1: Model # | Item Description| XS | S | M | L | XL|
ROW 2: 3241 | Gray Sweatshirt| | 20 | 20 | 30 | |
Basically this shows that there are 20 smalls, 20 mediums, and 30 larges of this particular item. There are no XS's or XL's.
I want to create a subquery that puts this information in one row, but at the same time, disinclude the sizes with a blank quantity amount as shown under the XS and XL sizes.
I want it to look like this when all is said and done:
ROW 1: MODEL #| 3241 | ITEM DESCRIPTION | Gray Sweatshirt | S | 10 | M | 20 | L | 30 |
Notice there are no XS or XL's included. How do I do make it so those columns do not appear?
Since you are not posting your query, nor your table structure, I guess it is with columns Id, Description, Size. If so, you could do this and just replace with your table and column names:
DECLARE #columns varchar(8000)
SELECT #columns = COALESCE (#columns + ',[' + cast(Size as varchar) + ']', '[' + cast(Size as varchar) + ']' )
FROM YourTableName
WHERE COUNT(Size) > 0
DECLARE #query varchar(8000) = 'SELECT Id, Description, '
+ #columns +'
FROM
(SELECT Id, Description, Size
FROM YourTableName) AS Source
PIVOT
(
COUNT(Size)
FOR Size IN ('+ #columns +')
) AS Pvt'
EXEC(#query)
Anyhow, I also agree with #MichaelFredickson. I have implemented this pivot solution, yet it is absolutely better to let the presentation layer to take care of this after just pulling the raw data from SQL. If not, you would be processing the data twice, one on SQL to create the table and the other in the presentation when reading and displaying the values with your c#/vb/other code.

powershell parsing of cdata-section

I'm trying to read an rss feed using powershell and I can't extract a cdata-section within the feed
Here's a snippet of the feed (with a few items cut to save space):
<item rdf:about="http://philadelphia.craigslist.org/ctd/blahblah.html">
<title>
<![CDATA[2006 BMW 650I,BLACK/BLACK/SPORT/AUTO ]]>
</title>
...
<dc:title>
<![CDATA[2006 BMW 650I,BLACK/BLACK/SPORT/AUTO ]]>
</dc:title>
<dc:type>text</dc:type>
<dcterms:issued>2011-11-28T22:15:55-05:00</dcterms:issued>
</item>
And the Powershell script:
$rssFeed = [xml](New-Object System.Net.WebClient).DownloadString('http://philadelphia.craigslist.org/sss/index.rss')
foreach ($item in $rssFeed.rdf.item) { $item.title }
Which produces this:
#cdata-section
--------------
2006 BMW 650I,BLACK/BLACK/SPORT/AUTO
2006 BMW 650I,BLACK/BLACK/SPORT/AUTO
How do I extract the cdata-section?
I tried a few variants such as $item.title."#cdata-section" and $item.title.InnerText which return nothing. I tried $item.title | gm and I see the #cdata-section listed as a property. What am I missing?
Thanks.
Since you have multiple of those, the title property itself would be an array, so the following should work:
$rss.item.title | select -expand "#cdata-section"
or
$rss.item.title[0]."#cdata-section"
based on what you need.