I have this table in ReST markup:
+---------------------------+-----------------------------------------------------------------+
| Option Line Kind | Distinguishing Characteristic |
+===========================+=================================================================+
| **Reference** | The option name is called a (node) reference, if the value\ |
| | of an option is a predefined keyword for the current node\ |
| | class. Because the option's value is a keyword, it can not\ |
| | be an interpolated value. |
+---------------------------+-----------------------------------------------------------------+
| **Option** | The option uses a defined option name valid for the current\ |
| | node class. The value can be a fixed or interpolated string. |
+---------------------------+-----------------------------------------------------------------+
| **User Defined Variable** | Otherwise an option line is a user defined variable. It can\ |
| | have fixed or interpolated string values. |
+---------------------------+-----------------------------------------------------------------+
Sphinx (ReadTheDocs theme) generates a horizontal scrollbar instead of breaking the content in column 2. The result is this mess:
What do I need to change in ReST (or the RTFD theme??) to let it break the text?
Edit:
The answer from #aflp91 results in this table:
Add a _static/custom.css file with
.wy-table-responsive table td {
white-space: normal;
}
Don't forget to declare it into conf.py:
def setup(app):
app.add_stylesheet('custom.css')
Works in my test…
You can use CSS property for table:
Overflow-x : hidden;
overflow-y : hidden;
Related
I have an HTML table with a column of cells containing two parts e.g.
| Cat (meow) |
+---------------------------+
| Long-dinosaur-name (roar) |
There are also other columns not shown. My users' browsers have unknown widths. On a wide one, I wish to show the cell as one line, as above. If it gets too narrow, I'm fine with wrapping
| Cat |
| (meow) |
+----------+
| Long- |
| dinosaur-|
| name |
| (roar) |
but if one line wraps, all lines must also wrap:
| Cat |
| (meow) |
+---------------------+
| Long-dinosaur-name |
| (roar) |
Without using Javascript, is it possible to do this?
I know I can use <td nowrap> to prevent wrapping, or <br> to force a wrap, but how can I make one cell depend on another?
Try using media query(CSS) with breakpoints. I know you said, the user browsers width's are unknown, but you can anticipate for different width's etc
Let's say I've got a table like this:
| RowID | LongString |
----------------------------------------
| 1 | This is a really long string |
| 2 | This is a shorter string |
How can I get a list of distinct words used in all the rows such as below:
| Result: |
-----------
| This |
| is |
| a |
| really |
| long |
| string |
| shorter |
From MySQL docs:
MySQL does not include a function to split a delimited string. Although separated data would normally be split into separate fields within a relation data, spliting such can be useful either during initial data load/validation or where such data is held in a text field.
So there is not ready-to-go solution. If I were you, I would split such string after fetching it from DB (it is easy to do in PHP, Java C# and so on).
Howewer on this site someone has wrote procedure for such task. Check it out. It is in comments section below.
I have a box which contains an image, which has float:left set, and textual contents.
-------------------------------------
|--------- |
|| | |
|| Image | |
|| | Content |
|--------- |
| |
| |
| |
--------------------------------------
Fig. 1
I generally consider it good to have the content float around the image. However, in case of using lists, the following look is annoying:
-------------------------------------
|--------- |
|| | List |
|| Image | |
|| | 1. Item |
|--------- 2. Item |
| 3. Item |
| 4. Item |
| |
--------------------------------------
Fig. 2
I'd rather have it the following way (at least for considerably short lists, let's assume the list is short for now)
-------------------------------------
|--------- |
|| | List |
|| Image | |
|| | 1. Item |
|--------- 2. Item |
| 3. Item |
| 4. Item |
| |
| Additional content (not in list) |
--------------------------------------
Fig. 3
I got the above look by making the list display: inline-block (and either inserting a <br> before the list, or wrapping it in a block-level element)
However, in case of any long list items (longer than the small width of the content field),
the float is cleared.
-------------------------------------
|--------- |
|| | |
|| Image | |
|| | |
|--------- |
| 1. Item |
| 2. A very long item, which makes |
| the list box just as wide as the|
| outer box. |
| 3. More items |
-------------------------------------|
Fig. 4
Why this happens seems clear to me. In the floated environment, first, the list is rendered as a block (because of display: inline-block), using the width of the outer box as environment width. As there is a long items, the resulting block will be as wide as the outer box. In a second step, the block is tried to fit next to the floating image, where it won't fit. Lastly, the float is cleared.
Is there any way to amend the situation? Like, first try to render the list with the shorter width, and if that fails, re-render? Or a completely different way to achieve what I want?
Put the list inside a DIV that is also floated left with a defined width.
Try a plain overflow:hidden on your list - this should do the trick.
See the example.
In my application, I allow users to create a form containing any HTML form field they want (e.g. text input, textarea, select, etc.). I want to give the users the ability to define 0 or more cumulative validation rules for each field (there might be up to 25 different validation rules). How should I model this?
Here's a potential solution:
============================================================
| Id | FieldId | ValidationRuleType | ValidationRuleDetail |
============================================================
| 1 | 25 | Required | NULL |
------------------------------------------------------------
| 2 | 26 | Minimum Length | 5 |
------------------------------------------------------------
| 3 | 26 | Maximum Length | 12 |
------------------------------------------------------------
...
Using the above design, maybe in most cases, the ValidationRuleType could just be "Regex" (or a value from a lookup table, such as ValidationRuleTypeId = 1 for "Regex"), and use the following for ValidationRuleDetail:
// Added bonus of this approach is that users who know regex could define their own patterns
.{1,} // Any character, 1 or more times. Use for "Required"
.{5,} // Any character, 5 or more times. Use for "Minimum Length = 5"
.{,12} // Any character, 12 or less times. Use for "Maximum Length = 12"
The problem is that this solution is EAV. That's a bad thing, right?
Another potential solution:
=============================================================
| Id | FieldId | Required | Minimum Length | Maximum Length |
=============================================================
| 1 | 25 | TRUE | NULL | NULL |
-------------------------------------------------------------
| 2 | 26 | NULL | 5 | 12 |
-------------------------------------------------------------
...
Is this better? I'm conflicted on which approach to use. Any guidance I can get is much appreciated.
The answer depends entirely on how you want the validation rules to work. If all you are going to have is required/min/max, then they should just be columns for the field (last option). If a validation rule defines a specific set of dynamic rules, they should be in their own table and a mapping between a validation rule and the field ID should exist (you should be able to map the same field ID to multiple validation rules in this case). Then you query for the fields, join with the mapping table and join with the rules to apply the rules to that field.
I want to have a column in a database that can contain multiple entries. Is it possible to have to define the type of the column as an array (fixed-sized array or some dynamic collection) so that it can store multiple entries.
If you require various values to be stored together, in a single field, then you will likely be best off storing them as a delimiter-separated string of values:
+----------------------------------+
| PRODUCTS |
+----------+-----------------------+
| Product | Colors |
+----------+-----------------------+
| Notebook | blue,red,green,orange |
+----------+-----------------------+
This is usually not what youw want though. Generally-speaking, the idea solution is to create relationships between tables. For instance:
+---------------+
| PRODUCT |
+----+----------+
| ID | Product |
+----+----------+
| 1 | Notebook |
+---------------+
+---------------+
| COLORS |
+----+----------+
| ID | Color |
+----+----------+
| 1 | Blue |
+---------------+
| 2 | Red |
+---------------+
| 3 | Green |
+---------------+
+---------------------+
| PRODUCTCOLORS |
+-----------+---------+
| ProductID | ColorID |
+-----------+---------+
| 1 | 1 | Notebook, Blue
+-----------+---------+
| 1 | 3 | Notebook, Green
+-----------+---------+
yes, in a typical relational design, you would have a 1:N (1-to-many) relationship between 1 table and another. each row in the first table represents a collection, each row in the second table is an element in a collection and references the first table.
a comma-separated list, serialize, or a url-encoded string is also a good solution as the other answers point out...
No, but what server side language are you using?
If using PHP you can use
$serializedArray = serialize($myArray);
And then insert that value into the db. To get it back out use unserialize();
This is pretty much the same answer as above (have a delimited string), but you could also save the text in that column as XML. Depending on the database you are using, that could be easy or tedious.
As pointed out above, is you obviously lose any aspect of being able to manage the data integrity from your DB layer (easily).