PDA

View Full Version : [CLOSED] TreeGrid - binding



adelaney
Sep 07, 2012, 4:07 PM
Is there a way from a controller to provide a TreeGrid with the hiearchy via direct method or action result so that it can "bind" (i.e. create a nodes structure)? If not there some other format XML or JSON which can be emitted from an ActionResult which can bind at the view level - sort of in the same way that a storeResult works for a regular grid?

Daniil
Sep 07, 2012, 4:17 PM
Hi,

Well, you just need to return a respective JSON which the TreeStore expects.

It should look something like this.

Example

[{
id: "01",
text: "01",
children: [{
/*children*/
}]
}, {
id: "02",
text: "02"
}, {
id: "03",
leaf: true,
text: "03"
}, {
id: "04",
leaf: true,
text: "04"
}]

You can generate this JSON as you wish.

Maybe, it would be useful for you to just populate NodeCollection, as here:
http://examples2.ext.net/#/TreePanel/Loaders/Using_Handler/

adelaney
Sep 07, 2012, 4:36 PM
Thanks. The example of the webservice call is really helpful. However, how does this work with custom attributes for the TreeGrid? Specifically, how do I tie the "fields" to the store?

Daniil
Sep 07, 2012, 5:38 PM
Please add the names of your CustomAttribitutes as the TreePanel Fields, as here:
http://examples2.ext.net/#/TreePanel/Advanced/TreeGrid/

I mean this

<Fields>
<ext:ModelField Name="task" />
<ext:ModelField Name="user" />
<ext:ModelField Name="duration" />
</Fields>

Then the CustomAttributes will become the Model fields.

adelaney
Sep 08, 2012, 2:06 AM
I am trying to load the nodes using a direct event and I am having some trouble. Here is my tree:


@(Html.X.TreePanel().ID("reinsurerTree") _
.Layout(LayoutType.Fit) _
.SortableColumns(False) _
.EnableColumnHide(False) _
.MinWidth(500) _
.Plugins(Html.X.CellEditing) _
.Scroll(ScrollMode.Both) _
.RootVisible(False) _
.Collapsible(False) _
.MultiSelect(False) _
.SingleExpand(False) _
.DirectEvents(Sub(evts)
evts.Load.Url = Url.Action("ReinsureTree", New With {.id = Model.RequestInformation.DocumentID})
End Sub) _
.TopBar(Sub(bar)
bar.Add(Html.X.Toolbar().Items(Html.X.ToolbarTextI tem().Text("This is the text.")))
End Sub) _
.Fields(Sub(flds)
With flds
.Add("Name")
.Add("UKCode")
.Add("ReinsurerCode")
.Add("DateReceivedFromRI")
.Add("DateSignedDocSentToRI")
.Add("TrackDates")
.Add("NeverSigning")
End With
End Sub) _
.ColumnModel(Sub(action)
action.Add(Html.X.Column().Text(" ").Width(30).Hideable(False))
action.Add(Html.X.Column().Text("Reinsurer Name").DataIndex("Name").Width(230))
action.Add(Html.X.Column().Text("UK").DataIndex("UKCode").Width(50).Align(Alignment.Right))
action.Add(Html.X.Column().Text("Code").DataIndex("ReinsurerCode").Width(50).Align(Alignment.Right))
action.Add(Html.X.DateColumn().Text("Date Sent<br/>to RI").Align(Alignment.Right).Editor(Sub(edtr)
edtr.Add(New Ext.Net.DateField())
End Sub))
action.Add(Html.X.DateColumn().Text("Date Received<br/>to RI").Align(Alignment.Right).DataIndex("DateReceivedFromRI").Align(Alignment.Right).Editor(Sub(edtr)
edtr.Add(New Ext.Net.DateField())
End Sub))
action.Add(Html.X.DateColumn().Text("Date Signed Doc<br/>Sent to RI").Align(Alignment.Right).DataIndex("DateSignedDocSentToRI").Align(Alignment.Right).Editor(Sub(edtr)
edtr.Add(New Ext.Net.DateField())
End Sub))
action.Add(Html.X.Column().Text("Follow-up<br/>Contact").Align(Alignment.Right).Width(100).Align(Alignmen t.Right))
action.Add(Html.X.CheckColumn().Text("Track<br/>Dates").DataIndex("TrackDates").Width(50).Align(Alignment.Center).Editable(True) )
action.Add(Html.X.CheckColumn().Text("Never<br/>Signing").DataIndex("NeverSigning").Width(50).Align(Alignment.Center).Editable(True) )
End Sub)
)

Here is my controller:


<DirectMethod()> _
Function ReinsureTree(ByVal id As Integer) As ActionResult
Dim reinsurer As List(Of CWReinsurer) = Me.Manager.Reinsurer.GetReinsurerByDocumentID(id)
Dim subReinsurer As List(Of CWReinsurer)
Dim topReinsurer As List(Of CWReinsurer)
Dim parentCode As String = ""
Dim sub_nds As New Ext.Net.NodeCollection(False)
Dim top_nds As New Ext.Net.NodeCollection(False)

topReinsurer = (From r In reinsurer Select r Where r.UKCode = "").ToList()
subReinsurer = (From r In reinsurer Select r Where r.UKCode <> "").ToList()

'Add Top Level reinsurers
With top_nds
For Each r In topReinsurer
Dim attrs As New List(Of Ext.Net.ConfigItem)
With attrs
.Add(New Ext.Net.ConfigItem With {.Name = "Name", .Value = r.Name, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "UKCode", .Value = r.UKCode, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "ReinsurerCode", .Value = r.ReinsurerCode, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "DateReceivedFromRI", .Value = r.DateReceivedFromRI, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "DateSignedDocSentToRI", .Value = r.DateSignedDocSentToRI, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "TrackDates", .Value = r.TrackDates, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "NeverSigning", .Value = r.NeverSigning, .Mode = ParameterMode.Value, .AutoDataBind = True})
End With

parentCode = r.ReinsurerCode
sub_nds.Clear()
'TODO:Refactor
For Each ri In subReinsurer.Where(Function(rein) rein.UKCode = parentCode).ToList()
Dim attrs1 As New List(Of Ext.Net.ConfigItem)
With attrs
.Add(New Ext.Net.ConfigItem With {.Name = "Name", .Value = ri.Name, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "UKCode", .Value = ri.UKCode, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "ReinsurerCode", .Value = ri.ReinsurerCode, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "DateReceivedFromRI", .Value = ri.DateReceivedFromRI, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "DateSignedDocSentToRI", .Value = ri.DateSignedDocSentToRI, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "TrackDates", .Value = ri.TrackDates, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "NeverSigning", .Value = ri.NeverSigning, .Mode = ParameterMode.Value, .AutoDataBind = True})
End With

sub_nds.Add(New Ext.Net.Node With {.Leaf = True, .Text = r.Name, .Expandable = False, .AttributesObject = attrs})
Next

top_nds.Add(New Ext.Net.Node With {.Leaf = (sub_nds.Count = 0), .Text = r.Name, .Expandable = False, .AttributesObject = attrs})
Next
End With
Return Direct(top_nds.ToJson())


Here's my model:


Namespace Models
Public Class CWReinsurer
#Region "Properties"

Public Property ID() As Integer
Get
Return _id
End Get
Set(ByVal value As Integer)
_id = value
End Set
End Property

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property

Public Property UKCode() As String
Get
Return _uKCode
End Get
Set(ByVal value As String)
_uKCode = value
End Set
End Property


Public Property ReinsurerCode() As String
Get
Return _reinsurerCode
End Get
Set(ByVal value As String)
_reinsurerCode = value
End Set
End Property


Public Property DateSentToRI() As Date
Get
Return _dateSentToRI
End Get
Set(ByVal value As Date)
_dateSentToRI = value
End Set
End Property


Public Property DateReceivedFromRI() As Date
Get
Return _dateReceivedFromRI
End Get
Set(ByVal value As Date)
_dateReceivedFromRI = value
End Set
End Property

Public Property DateSignedDocSentToRI() As Date
Get
Return _dateSignedDocSentToRI
End Get
Set(ByVal value As Date)
_dateSignedDocSentToRI = value
End Set
End Property

Public Property Transmit() As Boolean
Get
Return _transmit
End Get
Set(ByVal value As Boolean)
_transmit = value
End Set
End Property

Public Property TrackDates() As Boolean
Get
Return _trackDates
End Get
Set(ByVal value As Boolean)
_trackDates = value
End Set
End Property

Public Property NeverSigning() As Boolean
Get
Return _neverSigning
End Get
Set(ByVal value As Boolean)
_neverSigning = value
End Set
End Property

Public Property Reinsurers() As List(Of CWReinsurer)
Get
Return _reinsurers
End Get
Set(ByVal value As List(Of CWReinsurer))
_reinsurers = value
End Set
End Property

Public Property Parent() As CWReinsurer
Get
Return _parent
End Get
Set(ByVal value As CWReinsurer)
_parent = value
End Set
End Property
Public Property HasNonConcurrentTerms() As Boolean
Get
Return _hasNonConcurrentTerms
End Get
Set(ByVal value As Boolean)
_hasNonConcurrentTerms = value
End Set
End Property

Public Property NonConcurrentTermsText() As String
Get
Return _nonConcurrentTermsText
End Get
Set(ByVal value As String)
_nonConcurrentTermsText = value
End Set
End Property


Public Property ClientSigns() As Boolean
Get
Return _clientSigns
End Get
Set(ByVal value As Boolean)
_clientSigns = value
End Set
End Property


Public Property ReinsurerSigns() As Boolean
Get
Return _reinsurerSigns
End Get
Set(ByVal value As Boolean)
_reinsurerSigns = value
End Set
End Property

Public ReadOnly Property CodeAndName() As String
Get
Return String.Format("{0}: {1}", Me.ReinsurerCode, Me.Name)
End Get
End Property



#End Region
#Region "Local"
Private _id As Integer
Private _name As String
Private _uKCode As String
Private _reinsurerCode As String
Private _dateSentToRI As Date
Private _dateReceivedFromRI As Date
Private _dateSignedDocSentToRI As Date
Private _transmit As Boolean
Private _trackDates As Boolean
Private _neverSigning As Boolean
Private _reinsurers As List(Of CWReinsurer)
Private _parent As CWReinsurer
Private _hasNonConcurrentTerms As Boolean
Private _nonConcurrentTermsText As String
Private _clientSigns As Boolean
Private _reinsurerSigns As Boolean
#End Region
End Class
End Namespace


When I review the JSON, none of my attributes are output. Am I doing something wrong? Should I even need to render to JSON? Am I adding the attributes incorrectly?

Daniil
Sep 10, 2012, 6:28 AM
Could you clarify, please, why do you use a Load listener to call the controller action?

It doesn't know that it should load the nodes from a response to the TreePanel.

You should configure a TreeStore with an AjaxProxy setting the controller action URL.

The TreeStore expects just nodes in the response. So, you should not use an AjaxResult in this case, I mean:

Return Direct(top_nds.ToJson())

Please use

//C#
return Content(nodes.ToJson());
where the nodes is a NodeCollection.

adelaney
Sep 10, 2012, 6:50 AM
I have the load listner configured from some example I saw. However, I want the TreeGrid to load/callback after the page has loaded in order to speed up some response to the user - the page has a lot of items and database interaction. However, if there is a better/more correct way to do it, I am all for suggestion.

As for the TreeStore, I have fields configured becase this is a TreeGrid, not a Tree. When I configured both the fields and the store, the control erred out stating that I should pick one or the other (store or fields). Since I MUST have the TreeGrid, I went with fields.

Also, when outputting my code:


top_nds.ToJson()

None of my custom attributes, which I need for the fields was emitted.



With attrs
.Add(New Ext.Net.ConfigItem With {.Name = "Name", .Value = r.Name, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "UKCode", .Value = r.UKCode, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "ReinsurerCode", .Value = r.ReinsurerCode, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "DateReceivedFromRI", .Value = r.DateReceivedFromRI, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "DateSignedDocSentToRI", .Value = r.DateSignedDocSentToRI, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "TrackDates", .Value = r.TrackDates, .Mode = ParameterMode.Value, .AutoDataBind = True})
.Add(New Ext.Net.ConfigItem With {.Name = "NeverSigning", .Value = r.NeverSigning, .Mode = ParameterMode.Value, .AutoDataBind = True})

For some clarity, I have attached an image of what I am trying to recreate from the existing Windows application.

4746

For the example, the blackened areas are non-editable, but the rest is.

From earlier conversations, the TreeGrid was reported to be the best approach, but if after looking at the sample, it is not, please advise a better approach.

Daniil
Sep 10, 2012, 7:05 AM
I have the load listner configured from some example I saw. However, I want the TreeGrid to load/callback after the page has loaded in order to speed up some response to the user - the page has a lot of items and database interaction. However, if there is a better/more correct way to do it, I am all for suggestion.


Using a TreeStore with an AjaxProxy looks better solution according to the requirement details which you provided.

By default, it automatically initiates a load request if RootVisible is false. You can change this behavior setting AutoLoad to false for the TreeStore. Then you can initiate a load request when you wish.

Then it does a load request when nodes are expanded (if the children are not loaded yet).



As for the TreeStore, I have fields configured becase this is a TreeGrid, not a Tree. When I configured both the fields and the store, the control erred out stating that I should pick one or the other (store or fields). Since I MUST have the TreeGrid, I went with fields.


Yes, in this case you should set a Model with respective Fields for the TreeStore.



Also, when outputting my code:


top_nds.ToJson()

None of my custom attributes, which I need for the fields was emitted.


Please clarify where can you see they are omitted? In the response? Could you post that response?




For some clarity, I have attached an image of what I am trying to recreate from the existing Windows application.

4746

For the example, the blackened areas are non-editable, but the rest is.

From earlier conversations, the TreeGrid was reported to be the best approach, but if after looking at the sample, it is not, please advise a better approach.

Yes, I think the TreeGrid is the best control to implement your requirement. At least, it will allow to get a view similar in the screenshot and achieve the functionality that you need.

adelaney
Sep 10, 2012, 8:00 AM
I did as you stated and removed the fields while substituting the TreeStore. While I am at least getting something, I am not getting what I need.

First the JSON output is this:

"[{leaf:true,text:"Swiss Re Axxx Axxx/Swiss xxxxxxxxxx"}]"

I have attached an image for the output.
4747

For the Tree and the Grid, I have copied and pasted as much code that they have in common so as to make them the "same". As you can see, the tree does not have the column showing that I need - but the grid does. Additionally, as from the JSON, you can see that that data is missing. Am I not adding the data to the tree attributes accurately? Finally, even though I have columns configured for the tree, the column headings are showing either. Is there something special to configure to make that happen?

Daniil
Sep 10, 2012, 9:43 AM
Regarding AttributesObject.

I checked, they seems to be not serialized. It looks like a bug. We will investigate right now. Thank you for pointing it out.

For now, you can populate the CustomAttributes collection of the node.

By the way, you don't need to use ConfigItem with AttributesObject. It can look just:

Example (C#)

node.AttributesObject = new
{
testAttr1 = "testValue1",
testAttr2 = "testValue2"
};

Regarding columns.

One of the columns must be a TreeColumn, as here:
http://examples2.ext.net/#/TreePanel/Advanced/TreeGrid/

The rest columns can be any type of grid columns.

Daniil
Sep 10, 2012, 1:22 PM
Regarding AttributesObject.

I checked, they seems to be not serialized. It looks like a bug. We will investigate right now. Thank you for pointing it out.

For now, you can populate the CustomAttributes collection of the node.

By the way, you don't need to use ConfigItem with AttributesObject. It can look just:

Example (C#)

node.AttributesObject = new
{
testAttr1 = "testValue1",
testAttr2 = "testValue2"
};


It has been fixed in revision #4341. Thank you one more time for pointing the problem out!

adelaney
Sep 10, 2012, 5:06 PM
I am still struggling here and getting a tad exasperated. I have sent full example of my code. Have you run it? I still do not see any column headings. Do headings only show if the data makes it to the grid? Since the .ToJSon() is not emitting the nested objects is there ANYTHING else I can do to get the data to the grid? In my code, I do nothing special to create a "root." Is there something required in the code to create an empty root node which would make the columns show? In the view, I am only configuring the text property. While, I don't see a difference in the sample, is there somthing I am missing in configuration? I hate to push, but I really need some solid answers.

Daniil
Sep 11, 2012, 7:57 AM
I am still struggling here and getting a tad exasperated.

Thank you for your patience. We really need to solve the problem as quick as possible!


I have sent full example of my code. Have you run it? I still do not see any column headings.

No, I didn't, because I saw the obvious problems in this example which I pointed out further.

Generally, it is an issue with our time resources.

Commonly, the scheme is the following.



A member posts a sample code. As you did.
We look into it and point our the obvious problems without running the sample. As I did.
If a sample code is easy to run (without any changes from our side), we can run it to ensure our assumptions. Unfortunately, your code sample is not easy to run. The view is not full and no controller action for this view where you bind a Model. In addition, I am not the best in VB.NET to feel these gaps quickly. And, again, there are the obvious problems which 100% causes the sample to be not working.
If the issue persists, we do our best to run a sample. If we can't run, we request a member to apply required changes and/or provide him with our example as I will do right now.


Hopefully, this example will clarify everything and answer your questions. I simplified it as much as I can to demonstrate the main ideas.

Example View (C#)

<!DOCTYPE html>

<html>
<head>
<title>Ext.Net.MVC v2 Example</title>
</head>
<body>
@Html.X().ResourceManager()

@(Html.X().TreePanel()
.RootVisible(false)
.Store(Html.X().TreeStore()
.Model(Html.X().Model()
.Fields(
new ModelField("someCustomAttribute")
)
)
.Proxy(Html.X().AjaxProxy()
.Url(Url.Action("GetTreeData"))
)
)
.ColumnModel(
Html.X().TreeColumn()
.Text("Text")
.DataIndex("text"),
Html.X().Column()
.Text("Some custom attribute")
.DataIndex("someCustomAttribute")
.Width(200)
)
)
</body>
</html>


Example Controller Actions (C#)

public ActionResult TestRazor()
{
return View();
}

public ActionResult GetTreeData()
{
NodeCollection nodes = new NodeCollection();

Node node1 = new Node();
node1.Text = "Node 1";
node1.Leaf = true;
node1.CustomAttributes.Add(new ConfigItem("someCustomAttribute", "value 1", ParameterMode.Value));
nodes.Add(node1);

Node node2 = new Node();
node2.Text = "Node 2";
node2.Leaf = true;
node2.CustomAttributes.Add(new ConfigItem("someCustomAttribute", "value 2", ParameterMode.Value));
nodes.Add(node2);

return Content(nodes.ToJson());
}

Alternative GetTreeData (C#)

public ActionResult GetTreeData()
{
NodeCollection nodes = new NodeCollection();

Node node1 = new Node();
node1.Text = "Node 1";
node1.Leaf = true;
node1.AttributesObject = new
{
someCustomAttribute = "value 1"
};

nodes.Add(node1);

Node node2 = new Node();
node2.Text = "Node 2";
node2.Leaf = true;

node2.AttributesObject = new
{
someCustomAttribute = "value 2"
};
nodes.Add(node2);

return Content(nodes.ToJson());
}

We will be glad to help further if this example doesn't help.

adelaney
Sep 11, 2012, 5:50 PM
Thank you for your sample. It was very helpful. Even though I am providing code in VB, I am fully versed in C#. It is just the VB is the requirement where I am and there is no simple conversion tool for Razor.

As for the response, yes, I understand that this is a bit complex, but I have read that you guys want as much code as possible - especially considering that we were not making progress. Also, I do understand that you under time-constraints -as are we all. However, I was under the understanding that with the level of support we have purchased that there was a 24-hour turnaround for a response. For this issue, there have been lapses longer than that. At any rate, I do understand that volume sometimes gets rather high.

So, back to the sample...

I have it running , tested, and expanded it. So far, I have successfully seen column headings, added some features (like selectionModel, cell-editing, etc.), and added children. That's great. However, there is one troubling bit which essentially makes the grid 100% unusable. There is no data populating the columns. Now, from earlier conversation, we discovered that the .ToJSON did not seem to render out the Attributes. Your example includes the .ToJSON as part of the Content result. Since there is a bug in that, is there any other way I can get the data to the view - e.g. DirectMethod, DirectEvent, etc.? If not, that is a show-stopper for this UI element for me at this time. However, if there is another method, please let me know what that is so that I may verify that it will work as expected.

Again, thank you for your support.

Daniil
Sep 11, 2012, 6:27 PM
Thanks for the detailed answer. We will answer on all statements.

But, first of all, regarding the main problem.


However, there is one troubling bit which essentially makes the grid 100% unusable. There is no data populating the columns. Now, from earlier conversation, we discovered that the .ToJSON did not seem to render out the Attributes.

Yes, AttributesObject was not serialized, it was a bug and fixed pretty immediately:

It has been fixed in revision #4341. Thank you one more time for pointing the problem out!

Please clarify did you have a chance to update from SVN?

Also I pointed out that you use AttributesObject incorrectly:



By the way, you don't need to use ConfigItem with AttributesObject. It can look just:

Example (C#)

node.AttributesObject = new
{
testAttr1 = "testValue1",
testAttr2 = "testValue2"
};


However, before fixing I suggested another approach - CustomAttributes.

Regarding AttributesObject.

I checked, they seems to be not serialized. It looks like a bug. We will investigate right now. Thank you for pointing it out.

For now, you can populate the CustomAttributes collection of the node.


Please clarify did you have a chance to try CustomAttributes?

adelaney
Sep 11, 2012, 6:36 PM
Danill,

I apologize. I did not realize that there had been an update. I will download the latest version and test again.

Daniil
Sep 12, 2012, 3:42 AM
Please note that it should work without update if you would use CustomAttributes instead of AttributesObject.

adelaney
Sep 12, 2012, 12:59 PM
I can verify that it does. You may close the forum post.

Thanks!

adelaney
Sep 12, 2012, 5:10 PM
I do have a little bit more on this topic.

Now that I am able to get data to the TreeGrid, I am able to compare it to the Grid. They are both configured the same in the model and columns sections with the exception of the TreeGrid having the first column being set to a TreeColumn instead of a column. However, all the data is not showing. I have attached an image for reference.

4764

For some reason, the date and boolean data is not showing. I verified that it is being set when building the nodes. I have provided sample code below just for reference to ensure that I am setting the properties correctly.

Finally, if you will notice, I set the icon value in the node creation code. If anything other than the default, the image does not display. Is this by design or is this a bug?

Node Population:

Dim node As New Ext.Net.Node

With node
.Leaf = Not (hasSubNodes)
.Text = reinsurer.Name
.Expanded = True
If (Not hasSubNodes) Then
.Icon = Icon.Vcard
End If
With .CustomAttributes
.Add(New Ext.Net.ConfigItem With {.Name = "Name", .Value = reinsurer.Name, .Mode = ParameterMode.Value})
.Add(New Ext.Net.ConfigItem With {.Name = "UKCode", .Value = reinsurer.UKCode, .Mode = ParameterMode.Value})
.Add(New Ext.Net.ConfigItem With {.Name = "ReinsurerCode", .Value = reinsurer.ReinsurerCode, .Mode = ParameterMode.Value})
.Add(New Ext.Net.ConfigItem With {.Name = "DateReceivedFromRI", .Value = reinsurer.DateReceivedFromRI, .Mode = ParameterMode.Value})
.Add(New Ext.Net.ConfigItem With {.Name = "DateSignedDocSentToRI", .Value = reinsurer.DateSignedDocSentToRI, .Mode = ParameterMode.Value})
.Add(New Ext.Net.ConfigItem With {.Name = "TrackDates", .Value = reinsurer.TrackDates, .Mode = ParameterMode.Value})
.Add(New Ext.Net.ConfigItem With {.Name = "NeverSigning", .Value = reinsurer.NeverSigning, .Mode = ParameterMode.Value})
End With
End With

Return node

This is the model:

.Model(Sub(mdl)
mdl.Add(Html.X().Model.Fields(Sub(fields)
fields.Add(Html.X.ModelField.Name("Name"))
fields.Add(Html.X.ModelField.Name("UKCode"))
fields.Add(Html.X.ModelField.Name("DateSentToRI").Type(ModelFieldType.Date))
fields.Add(Html.X.ModelField.Name("DateSignedDocSentToRI").Type(ModelFieldType.Date))
fields.Add(Html.X.ModelField.Name("ReinsurerCode"))
fields.Add(Html.X.ModelField.Name("TrackDates").Type(ModelFieldType.Boolean))
fields.Add(Html.X.ModelField.Name("DateReceivedFromRI").Type(ModelFieldType.Date))
fields.Add(Html.X.ModelField.Name("NeverSigning").Type(ModelFieldType.Boolean))
End Sub))

And these is the columns:

.ColumnModel(Html.X.TreeColumn().Text("ReinsurerName").DataIndex("Name").Width(230),
Html.X.Column().Text("Code").DataIndex("ReinsurerCode").Width(50).Align(Alignment.Right),
Html.X.DateColumn().Text("Date Sent<br/>to RI").Align(Alignment.Right) _
.Editor(Sub(edtr)
edtr.Add(New Ext.Net.DateField())
End Sub),
Html.X.DateColumn().Text("Date Received<br/>from RI").Align(Alignment.Right).DataIndex("DateReceivedFromRI") _
.Align(Alignment.Right) _
.Editor(Sub(edtr)
edtr.Add(New Ext.Net.DateField())
End Sub),
Html.X.DateColumn().Text("Date Signed Doc<br/>Sent to RI").Align(Alignment.Right).DataIndex("DateSignedDocSentToRI") _
.Align(Alignment.Right) _
.Editor(Sub(edtr)
edtr.Add(New Ext.Net.DateField())
End Sub),
Html.X.Column().Text("Follow-up<br/>Contact").Align(Alignment.Right).Width(100).Align(Alignmen t.Right),
Html.X.CheckColumn().Text("Track<br/>Dates").DataIndex("TrackDates").Width(50).Align(Alignment.Center).Editable(True) ,
Html.X.CheckColumn().Text("Never<br/>Signing").DataIndex("NeverSigning").Width(50).Align(Alignment.Center).Editable(True)
)

Daniil
Sep 12, 2012, 6:32 PM
For some reason, the date and boolean data is not showing. I verified that it is being set when building the nodes. I have provided sample code below just for reference to ensure that I am setting the properties correctly.


I think it is a serialization issue.

What exactly data does come from the controller action?

Regarding dates.

The default date format of date type ModelField is ""yyyy-MM-ddTHH:mm:ss"". So, the bound dates must in this format to be parsed.

Possible solutions:

1. Set a respective DateFormat for the ModelField.

2. Use JSON.NET serialization in the controller action.
2.1. Use AttributesObject instead of CustomAttributes. It is serialized using JSON.NET.

Example

node.AttributesObject = new
{
someCustomAttribute = DateTime.Now
};

or

2.2. Use JSON.NET serialization explicitly with CustomAttributes.

Example

node.CustomAttributes.Add(new ConfigItem("someCustomAttribute", JSON.Serialize(DateTime.Now), ParameterMode.Raw));


Regarding boolean.

I guess there are "True" and "False" strings in the data returned by the controller action. It must be JavaScript true and false, not strings.

Possible solutions:

1. CustomAttributes + "true"/"false" strings + ParameterMode.Raw

Example

node.CustomAttributes.Add(new ConfigItem("someCustomAttribute", "true", ParameterMode.Raw));

2. AttributesObject

Example

node.AttributesObject = new
{
someCustomAttribute = true
};




Finally, if you will notice, I set the icon value in the node creation code. If anything other than the default, the image does not display. Is this by design or is this a bug?


I just checked - it works well for me, i.e. I can see non default icons.

Can you see this code within a response of the controller action?

iconCls:X.net.RM.getIcon("Vcard")

P.S. All examples are done with C#.

Daniil
Sep 13, 2012, 8:04 AM
Even though I am providing code in VB, I am fully versed in C#.

It is very good. Thank you for clarification.



As for the response, yes, I understand that this is a bit complex, but I have read that you guys want as much code as possible - especially considering that we were not making progress.

Actually, that is a bit incorrect. Generally, a single thing which we really want - to help as faster as we can. In most cases, providing us with a sample which we can copy, paste and run locally without any changes gives the best chance for us to provide you with a solution as faster as we can. We don't require as much code as possible, we require only relevant to the problem code. So, before posting, if you have a chance, please simplify samples as much as you can leaving only required things to reproduce the problem.