XtraTreeList ExporttoXML - c#

I tried xtraTreeList's exporttoXML property. But the generated xml does not contain any information of the node like ID or is Chcked etc and just the name and parentID. Is there any other export property which will give all the information ?

TreeList.ExportToXml(String) Method exports the tree list's data
to the specified file as XML not the layout. You can use
TreeList.SaveLayoutToXml(String) Method to save the layout and
restore it by using TreeList.RestoreLayoutFromXml(String) Method.
Code snippet:
string fileName = "c:\\TreeListLayout.xml";
treeList1.SaveLayoutToXml(fileName);
treeList2.DataSource = treeList1.DataSource;
treeList2.RestoreLayoutFromXml(fileName);
Go Through DevExpress Example How to preserve the expanded state of TreeList nodes when refreshing data and the following reference links.
Ref:
How to load and save the layout of a TreeList by code
SearchResult
Hope this help..

Related

How to Dynamically fetch the fields from item in Sitecore using C# code?

I have a template called 'Footer' which contains a Rich-Text Field.
Using the Footer Template I have created an Item called 'FooterComponent' and filled in the Rich-Text Field.
I have a sublayout called 'Footer-Sublayout' and Mapped the Visual studio sublayout with this.
Using Footer-Sublayout C# code I have to fetch the Rich-Text field from the 'FooterComponent' and display it in my Home Page.
You need to add the footer sublayout to the presentation detail of the homepage and bind it to the placeholder that corresponds to the one in the code.
In the code behind of the footer sublayout, you will then need to fetch the value from the rich text field of the item. So, first get the footer item either by path or template ID. Second, read the value of the rich text field.
Thanks
Give your Footer-Sublayout a datasource. In your code you can request the datasource of the rendering/sublayout (the exact how can differ, depending on the sitecore version, frameworks used (glass, ..) but can be easily found).
By using a datasource (and not hardcoding the item in your code) you give your editors the ability to change the item without changing code - or use the personalization/testing features of Sitecore.
e.g. (in v7 without frameworks):
public Item GetDataSource(Control parent)
{
var sublayout = parent as Sublayout;
return sublayout != null ? Context.Database.GetItem(sublayout.DataSource) : null;
}
Use the parent of your control in this function to retrieve the datasource item. Once you have the item, you can attach it to a FieldRenderer or fetch the fields in code.

Merge Rich Text ( HTML ) to Word Document Content Control using Open XML

I have a word template which has a content control placeholder to hold rich text data. The data comes from a sharepoint list (rich text field) and may also include tables in it.
On checking the data from sharepoint list I found it returns me a HTML formatted data. I wish to place this data in the content placeholder with proper formatting.
For example if the data returned is HTML table ( format) I want a table to be created with data populated. Is there any method available to place the data in content control.
I found that third party tool converter at http://html2openxml.codeplex.com/ which is available for conversion, however this appends data to MainDocumentPart not to content control.
Please guide. Thanks in advance.
You could try to use WordDocGenerator, which uses content controls. Then combine it with html2openxml, as discussed here. However, I find the formatting in some cases becomes terrible after adding the html content into your content control--one example is when inserting lists, the bullet points goes out of view when you open the document. I have not tried adding a whole table into a content control.

Adding links in XML an reading it to dataset to populate grid view

I have a requirement of getting data from xml file and showing that data in a grid view in c# windows application.
I have done that successfully using dataset.ReadXml() method.
But what i originally want is that ,i need to have certain links in my XML file.Then i have to show that link in the grid view.
E.g here is my sample xml
<gallery heading="Photography">
<piece>
<heading>Piece 1</heading>
<desc><![CDATA[<a href='http://www.yourUrlGoesHere.com' target='_blank'>text</a>]]></desc>
<image>1.jpg</image>
</piece>
<piece>
<heading>Piece 2</heading>
<desc><![CDATA[<a href='http://www.yourUrlGoesHere.com' target='_blank'>text</a>]]></desc>
<image>2.jpg</image>
</piece>
</gallery>
When i read this xml into a dataset then dataset is coming as empty,i guess it is due to the a href thing.When i removed the href thing then data grid populated correctly.What is the problem here?
Can anyone help me to get over this.
Any help will be appreciated.Please help anyone.
Thanks

Get entire dropdown list items into an array in InfoPath

I have an InfoPath XSN form template with a dropdown list. This is bound at design time to a data source and populated with a list of names when the form is loaded.
I would like to get hold of all of the names in this dropdown list into an array for processing elsewhere on that form. I have tried to get hold of a reference to the dropdown list as below (and similar variations);
XPathNavigator myNav = this.MainDataSource.CreateNavigator();
object dd = myNav.Select("/dfs:myFields/dfs:queryFields/q:Site/#STitle", this.NamespaceManager).Current;
But I'm only getting the current value and not able to get hold of the entire list. Any one able to help please?
You can attach to the datasource you bound the listbox to (a secondary data source) the same way you are attaching to your primary.
XPathNavigator myNav = this.DataSources["datasourcename"].CreateNavigator();
Then just use the navigator to work with the fields/nodes as normal XML, so you can put them in array or just use the collection of nodes or whatever.
The MS documenation has some simple examples of connecting to a secondary data source and selecting nodes (among other things).
http://msdn.microsoft.com/en-us/library/office/bb509311(v=office.12).aspx

Attribute is not updating using LINQ TO XML?

I load an xml file into an Xelement. I then look for an an element named R via:
XElement elem = xmlTemplate.Descendants().Where(x => x.Name.LocalName == "R").FirstOrDefault();
I then search for the attributes EF and EX via:
elem.Attribute("EF").SetValue(txtEffective.Text);
elem.Attribute("EX").SetValue(txtExpire.Text);
but when I call xTemplate.Save(...), it does not save the udpated attributes. I have also tried:
elem.Attribute("EF").Value = txtEffective.Text;
elem.Attribute("EX").Value = txtExpire.Text;
I found out the problem, but not sure how to avoid it. When I load the XML, I am loading the two attributes in two text boxes on the form. When I change the values in the text box to update the attributes, it is updating the xml with the original values in the text box and not new ones. I wonder if this has to do with the fact that the text boxes are loaded on page load and when I click the button, it actually loads the xml again and overwrites my new values with the original values. After I did not load the values in the text box, the save worked fine.

Categories

Resources