Skip to content

Commit

Permalink
Adding InHidden for Cell in LayoutXML. #889
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed May 18, 2023
1 parent 1e2412f commit 1de4b7c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
4 changes: 1 addition & 3 deletions FetchXmlBuilder/Extensions/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Rappen.XTB.FetchXmlBuilder.Builder;
using Microsoft.Xrm.Sdk.Metadata;
using Microsoft.Xrm.Sdk.Metadata;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;

namespace Rappen.XTB.FetchXmlBuilder.Extensions
{
Expand Down
27 changes: 18 additions & 9 deletions FetchXmlBuilder/Views/Cell.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Rappen.XTB.FetchXmlBuilder.Builder;
using Rappen.XTB.FetchXmlBuilder.Extensions;
using Rappen.XTB.FetchXmlBuilder.Extensions;
using System.Windows.Forms;
using System.Xml;

Expand All @@ -9,6 +8,7 @@ public class Cell
{
public string Name;
public int Width;
public bool IsHidden;
public TreeNode Attribute;
public LayoutXML Parent;

Expand All @@ -21,21 +21,30 @@ internal Cell(LayoutXML layoutxml, XmlNode cell)
{
Parent = layoutxml;
Name = cell.AttributeValue("name");
if (int.TryParse(cell.AttributeValue("width"), out int width))
var ishiddenstr = cell.AttributeValue("ishidden").ToLowerInvariant();
if (!int.TryParse(cell.AttributeValue("width"), out int width))
{
Width = width;
}
else
{
Width = 100;
width = 100;
}
IsHidden = ishiddenstr == "1" || ishiddenstr == "true" || width == 0;
Width = IsHidden ? 0 : width;
}

public override string ToString() => $"{Name} ({Width})";

public string ToXML()
{
return $"<cell name='{Name}' width='{Width}' />";
var result = $"<cell name='{Name}' ";
if (IsHidden || Width < 1)
{
result += "ishidden='1' ";
}
else
{
result += $"width='{Width}' ";
}
result += "/>";
return result;
}

public int DisplayIndex => (Parent?.Cells.IndexOf(this) ?? 0) + 1;
Expand Down
2 changes: 1 addition & 1 deletion FetchXmlBuilder/Views/LayoutXML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public string ToXML()
{
var result = $@"<grid name='resultset' object='{EntityMeta?.ObjectTypeCode}' jump='{EntityMeta?.PrimaryNameAttribute}' select='1' icon='1' preview='1'>
<row name='result' id='{EntityMeta?.PrimaryIdAttribute}'>
{string.Join("\n ", Cells?.Where(c => c.Width > 0).Select(c => c.ToXML()))}
{string.Join("\n ", Cells?./*Where(c => c.Width > 0).*/Select(c => c.ToXML()))}
</row>
</grid>";
return result;
Expand Down

0 comments on commit 1de4b7c

Please sign in to comment.