When I generate my docfx documentation, my Fields have the proper <name> and <description> columns. However, a nested table is created inside the description column that can be fairly large and it leaves the <name> column with a lot of empty space (see Figure 1). I was wondering if it is possible to make it span all the columns or place it under the parent table?
What it looks like:
What I want it to look like:
I inspected the developer tools and the tables have the exact same class so I could not think of a way to solve this problem without manually going in and changing them.
Related
I'm currently testing various reporting tools and came across to List & Label from Combit, which makes a very solid impression. As part of a PoC, I first integrated it into a simple C# Winforms application and attached a SQL Server database.
...
using(ListLabel myLL = new ListLabel())
{
SqlConnection connection = new SqlConnection(Properties.Settings.Default.ConnectionString);
myLL.DataSource = new SqlConnectionDataProvider(connection);
myLL.Design();
}
...
However, I don't understand why with the data structure in the designer I can't then also see the relational structure in/from the database.... all relations seem to be just ignored. I can only see all tables at the root level - even though they are a relation in the SQL Server database.
Couldn't find any information for this so far unfortunately - ideas?
Actually, it's all there usually. You should be able to see the full structure, as soon as you add a report container:
This way, you can add e.g. "Order Details" either as a sub element of the customers (like shown in the screenshot) or as a top level element (if I had selected it from the root of the list).
The field tree on the other hand just shows the available tables with their contents ("fields"). As each table may appear in different levels of the hierarchy, it's only added once to the tree, while the hierarchy is defined when adding a new table.
One exception from this rule is the 1:1 related identifiers of parent tables. As it might well be required to print e.g. Customer data related to an order line in a "Orders" table, you cann access them directly from the field tree:
Thus, you actually do see the relations there, albeit in reverse order. While this might seem confusing at first it really makes sense once you get your head around the concept.
I am trying to insert a new element into the XmlNode in C# code,
How to insert the <delimiter>##<delimiter> element in inside the "/TestBooks/template/field" root. (Screenshot1)
enter image description here
Inside the <field> element, i need to insert the <delimiter> element, based on id element <Id>11-09-2020-505</Id>. (Screenshot2)
enter image description here
First of all you really shouldn't use pictures in questions -- we are taking the time to type you an answer you can take the time to use copy and paste and format your questions.
I'd like to answer your questions but I'm concerned about the questions because it implies that you are adding in markers to aid in the parsing of the data. You really shouldn't need to parse XML.
There are many great parsers of XML including one built into C# you should not roll your own.
In the XML standard the order of the children not defined. If you put a child as the "first" child, there is no reason to expect that a parser would list it as first.
(To have order in children you should just add an order attribute)
Because of these reason it should not matter where in the list of children you add the child.
So we can tell you how to add a child but we can't "put it in a specific spot" since children don't have an order.
In summary, it is not possible to do what you ask.
Let's say I have two fields (one under another). By default I want to have both of them rendered, but when the first field is empty, I would like the second one to take its place. Is there any convenient way to achieve this?
Note: My problem is much more complex, and a "scalable" solution would be highly appreciated.
I've found a cumbersome method, but I'm still looking for something better.
I finally came up with a better solution. The solution is to create a table in a DataSet, and insert a subreport selecting the table as its data source. Now you can add rows dynamically to the table (depending on some conditions).
I'm a PHP programmer, and I'm trying to understand some code which I think is ASP.NET. This is also my first foray into XML. I don't have access to a Windows box to test on.
I need to produce XML output that third-party code can use. The third party wants to use our data instead of the data source they are currently using. I don't want to replicate the current XML structure exactly because it doesn't map well to our data.
The structure of the current XML is very flat. There are only a few nested elements and the third party doesn't make use of any of them. The third party does have a sub-contracted programmer, but he is very busy. Also, I want to understand, for myself, how this works.
This is an excerpt from a plugin for a custom CMS:
Dim obj_set As New Data.DataSet()
Using obj_reader As New System.Xml.XmlTextReader("http://www.example.com/xml_output.php")
obj_set.ReadXml(obj_reader)
End Using
Dim obj_view As Data.DataView = obj_set.Tables("profile").DefaultView
obj_view.Sort = "cname"
Dim obj_data As Data.DataTable = obj_view.ToTable()
So from what I have gathered so far, this code
reads the XML file into a DataSet
sorts the profile table by cname
creates a new DataTable from the sorted view
There is other code that stores the new table to, and retrieves it from, cache. Then there is code that loops through the table rows and maps the column names to template variables.
Sample excerpt of current XML structure:
<profiles>
<profile>
<cname>ABC Corporation</cname>
<fname>John</fname>
<lname>Smith</lname>
<sector>Widgets</sector>
<subsectors>
<subsector>Basic Widgets</subsector>
<subsector>Fancy Widgets</subsector>
</subsectors>
</profile>
</profiles>
So what happens to the subsectors data? Does the reader create a separate table for it? If so, how are the tables related?
Our data includes multiple contacts per company. I could just create multiple elements at the top level fname1, fname2, fname3 to keep the flat structure. But I was thinking a nested structure makes sense for this kind of data. The problem is that I don't understand if such a structural change is compatible with the plugin code.
What kinds of changes would need to be made to the plugin code to make use of nested elements?
I was stumped on this myself, and I don't know if you still are, but for reference to others here's what I found.
You are right in assuming that the reader creates a separate table for it. Being that a DataSet can hold multiple tables, each "level" of elements gets its own table. However, any nested elements that have nested elements of their own will get their own table. Essentially, it keeps creating tables until it reaches the bottom of the xml tree. If an element has no children, it gets added as a cell in the data table.
In your case,
dataSet.Tables[0] will hold the top level nodes (all the <.profiles>). But since the nested element <.profile> has elements of its own, Tables[0] will likely only have one row. The next level deeper, dataSet.Tables[1] will hold all <-profile> nodes. Although since <.subsectors> has sub-element <.subsector>, it will not be in Tables[1], but rather in Tables[2] which goes yet level deeper.
I know it has been a while since this was asked, but hopefully this will be helpful.
In my database, I have a parent and child tables.
For example, parent table contains last name and address, and child table contains last and first name.
There is a foreign key, so that a row in child table must have corresponding last-name in parent table.
When I read those two tables using 2 DataAdapter's, and add those DataTable's to DataSet, I'd like to print XML, that looks like this:
<parent_table>
<last_name>Smith</last_name>
<address>111 Hi Street, Bye city</address>
<child_table>
<last_name>Smith</last_name>
<first_name>Ann</first_name>
</child_table>
<child_table>
<last_name>Smith</last_name>
<first_name>Bob</first_name>
</child_table>
</parent_table>
However, at present I'm getting two tables printed separately:
<parent_table>
<last_name>Smith</last_name>
<address>111 Hi Street, Bye city</address>
</parent_table>
<child_table>
<last_name>Smith</last_name>
<first_name>Ann</first_name>
</child_table>
<child_table>
<last_name>Smith</last_name>
<first_name>Bob</first_name>
</child_table>
Is there a way to achieve (hopefully using DataSet.WriteXML()) my desired output?
I tried adding ForeignKeyConstraint, and tried adding DataRelation, but neither changed the output.
Disclaimer: the above was hand-written, so please excuse if there's an error in XML. The actual tables contain better foreign key than 'last-name'.
From Writing DataSet Contents as XML Data (ADO.NET):
When writing an XML representation of a DataSet that contains
DataRelation objects, you will most likely want the resulting XML to
have the child rows of each relation nested within their related
parent elements. To accomplish this, set the Nested property of the
DataRelation to true when you add the DataRelation to the DataSet. For
more information, see Nesting DataRelations (ADO.NET).