Xamarin Forms Grid in a TableView - ios

I am creating a financial app and need to show a table with section headers and many grids.
In the attached screenshot I am almost there. I need the first column to Left align (start) and the rows to be about double their default height.
var content = new TableView
{
Intent = TableIntent.Data,
Root = new TableRoot("Performance"),
BackgroundColor = Color.Green
};
content.Root.Add(GetTableSection("Monthly", Model.Monthly);
.................
private TableSection GetTableSection(string title, List<PerformanceRow> performanceRows)
{
TableSection section = new TableSection()
{
Title = title
};
foreach (var row in performanceRows)
{
Grid grid = new Grid
{
VerticalOptions = LayoutOptions.FillAndExpand,
HeightRequest = 100, //?????????
BackgroundColor = Color.Red,
ColumnDefinitions =
{
new ColumnDefinition {Width = new GridLength(.3, GridUnitType.Star)},
new ColumnDefinition {Width = new GridLength(.3, GridUnitType.Star)},
new ColumnDefinition {Width = new GridLength(.3, GridUnitType.Star)},
}
};
//First Row
grid.Children.Add(new Label {Text = row.Title, HorizontalOptions = LayoutOptions.Start}, 1, 0);
grid.Children.Add(new Label {Text = "Market Value"}, 2, 0);
grid.Children.Add(new Label {Text = row.MarketValue.ToString("C"), HorizontalOptions = LayoutOptions.End}, 3, 0);
//Second Row
grid.Children.Add(new Label {Text = " "}, 1, 1);
grid.Children.Add(new Label {Text = "Return"}, 2, 1);
grid.Children.Add(new Label {Text = row.ReturnRate.ToString("C"), HorizontalOptions = LayoutOptions.End}, 3, 1);
section.Add(new ViewCell()
{
View = grid,
Height = 100 //??????????
});
}
return section;
}

This worked:
Set the UnevenRows to true for the tableview, then the table intent to rows

Related

i am new in action script. trying to split a sentence into words and show them in sprite.and also need which sprite i clicked

I am trying to split a sentence in to words and show them into sprite()
var sentence:String = "My name is Subhadip.";
var txt:Array = new Array();
var splittedSentence:Array = sentence.split(" ");
var myArraySprites:Array = new Array();
var myTextImage:Array = new Array();
var div = 40;
for (var i:int = 0; i < splittedSentence.length; i++)
{
var v = 300 - (div * i);
//...
txt[i] = new TextField();
txt[i].autoSize = TextFieldAutoSize.CENTER;
txt[i].text = splittedSentence[i];
var format1:TextFormat = new TextFormat();
format1.size = 24;
txt[i].setTextFormat(format1);
trace(txt[i]);
myArraySprites[i] = new Sprite();
myArraySprites[i].graphics.lineStyle(1, 0x000000, 1);
myArraySprites[i].buttonMode = true;
myArraySprites[i].graphics.beginFill( 0xfffffff );
myArraySprites[i].graphics.drawRect(50, v, 150, div);
myTextImage[i] = new BitmapData(100,v,true,0xffffff);
myTextImage[i].draw(txt[i]);
trace(myTextImage[i]);
//myArraySprites[i].graphics.beginBitmapFill(myTextImage[i]);
//myArraySprites[i].graphics.endFill();
myArraySprites[i].addChild(new Bitmap(myTextImage[i]));
addChild(myArraySprites[i]);
myArraySprites[i].addEventListener(MouseEvent.CLICK, removeThis);
}
function removeThis(e:MouseEvent):void
{
var clickTarget:int = myArraySprites.indexOf(e.currentTarget);
trace("Clicked sprite (id): " + clickTarget);
}
[enter image description here][1]
trying to split a sentence into words and show them in sprite.and also need which sprite i clicked
[1]: https://i.stack.imgur.com/RzHUQ.png
The problem is that you're dealing with screen positions in two different places:
myArraySprites[i].graphics.drawRect(50, v, 150, div);
and
myTextImage[i] = new BitmapData(100,v,true,0xffffff);
Think of it in a more object-oriented way. Each Sprite instance you want to be clickable is a single object. As such it also holds the main properties e.g. the on-screen position determined by it's x and y properties.
Each of those sprites have equal width & height, so make this a global property.
var wid:Number = 150;
var hei:Number = 40;
If we look at your .png, we can see that you want to have a single word centered inside such a sprite. To make things easier, we can use the .align property of the TextFormat class, set it to "center" and make each TextField 150 x 40 by using the wid and hei properties.
Finally each sprite's vertical screen position is shifted up by hei == 40 pixels. So let's determine a start position:
var yPos:Number = 300;
assign it to a sprite instance:
myArraySprites[i].x=50;
myArraySprites[i].y=yPos;
and decrement it by hei inside the for-loop.
Everything put together:
var yPos:Number = 300;
var wid:Number = 150;
var hei:Number = 40;
var sentence:String = "My name is Subhadip.";
var txt:TextField = new TextField();
txt.width = wid;
txt.height = hei;
var format1:TextFormat = new TextFormat();
format1.size = 24;
format1.align = "center";
var splittedSentence:Array = sentence.split(" ");
var myTextImage:Array = new Array();
for (var i:int = 0; i<splittedSentence.length; i++)
{
txt.text = splittedSentence[i];
txt.setTextFormat(format1);
myArraySprites[i] = new Sprite();
myArraySprites[i].x = 50;
myArraySprites[i].y = yPos;
myArraySprites[i].graphics.lineStyle(1, 0x000000, 1);
myArraySprites[i].buttonMode = true;
myArraySprites[i].graphics.beginFill(0xfffffff);
myArraySprites[i].graphics.drawRect(0, 0, wid, hei);
myTextImage[i] = new BitmapData(wid, hei, true, 0xffffff);
myTextImage[i].draw(txt);
myArraySprites[i].addChild(new Bitmap(myTextImage[i]));
addChild(myArraySprites[i]);
myArraySprites[i].addEventListener(MouseEvent.CLICK, removeThis);
yPos -= hei;
}

goneMargin in ConstraintLayout with Compose

I'm trying to use ConstraintLayout in Compose. I want the second Composable to be constrained at the end of the first Composable. The first composable can exist or not. In each case, I would like to have different margins. Thus, I use goneMargin but this seems to not be respected. Do I need to do something else?
ConstraintLayout {
val (firstItemRef, secondItemRef) = createRefs()
if (isFirstItemVisible) {
Text(
text = "First",
modifier = Modifier.constrainAs(firstItemRef) {
top.linkTo(anchor = parent.top)
start.linkTo(anchor = parent.start)
}
)
}
Text(
text = "Second",
modifier = Modifier.constrainAs(secondItemRef) {
top.linkTo(anchor = parent.top)
start.linkTo(anchor = firstItemRef.end, margin = 8.dp, goneMargin = 16.dp)
}
)
}
As a workaround, we could do something like that, but this seems to counterfeit the purpose of goneMargin
Text(
text = "Second",
modifier = Modifier.constrainAs(secondItemRef) {
val margin = if (isFirstItemVisible) 8.dp else 16.dp
val end = if (isFirstItemVisible) firstItemRef.end else parent.end
top.linkTo(anchor = parent.top)
start.linkTo(anchor = end, margin = margin)
}
)
You have to use the visibility property in ConstrainScope like this:
ConstraintLayout(Modifier.fillMaxSize()) {
val (firstItemRef, secondItemRef) = createRefs()
Text(
text = "First",
modifier = Modifier.constrainAs(firstItemRef) {
top.linkTo(anchor = parent.top)
start.linkTo(anchor = parent.start)
// >> This is what you want <<<
visibility = if (isFirstItemVisible) Visibility.Visible else Visibility.Gone
}
)
Text(
text = "Second",
modifier = Modifier.constrainAs(secondItemRef) {
top.linkTo(anchor = parent.top)
start.linkTo(anchor = firstItemRef.end, margin = 8.dp, goneMargin = 16.dp)
}
)
}

OpenXml can't open docx file after vertically merged cells,

string path = #"D:\newdoc.docx" ;
using (WordprocessingDocument doc = WordprocessingDocument.Create(path, WordprocessingDocumentType.Document))
{
MainDocumentPart mainpart = doc.AddMainDocumentPart();
mainpart.Document = new Document();
Body body = mainpart.Document.AppendChild(new Body());
Table t = new Table();
TableProperties tpr = new TableProperties(new TableWidth(){Width="0",Type=TableWidthUnitValues.Auto},new TableLook(){Val="04A0"});
t.Append(tpr);
TableGrid tg = new TableGrid(new GridColumn() { Width = "4261" }, new GridColumn() { Width = "4261" });
t.Append(tg);
TableRow tr1 = new TableRow();
TableCell r1tc1 = new TableCell();
TableCell r1tc2 = new TableCell();
tr1.Append(r1tc1);
tr1.Append(r1tc2);
TableRow tr2 = new TableRow();
TableCell r2tc1 = new TableCell();
TableCell r2tc2 = new TableCell();
tr2.Append(r2tc1);
tr2.Append(r2tc2);
TableRow tr3 = new TableRow();
TableCell r3tc1 = new TableCell();
TableCellProperties r3tc1prp = new TableCellProperties();
VerticalMerge vm = new VerticalMerge() { Val = MergedCellValues.Restart };
r3tc1prp.Append(vm);
r3tc1.Append(r3tc1prp);
TableCell r3tc2 = new TableCell(new TableCellProperties());
tr3.Append(r3tc1);
tr3.Append(r3tc2);
TableRow tr4 = new TableRow();
TableCell r4tc1 = new TableCell();
r4tc1.TableCellProperties = new TableCellProperties(new TableCellWidth() { Width = "4261", Type = TableWidthUnitValues.Dxa });
r4tc1.TableCellProperties.VerticalMerge = new VerticalMerge();
TableCell r4tc2 = new TableCell();
tr4.Append(r4tc1);
tr4.Append(r4tc2);
t.Append(tr1);
t.Append(tr2);
t.Append(tr3);
t.Append(tr4);
body.Append(t);
}
after create and saved the document, I can't open it with Word2007
Error:<p> element must before element </tc>
I can't find <p> element in document.xml
troubled me for several days ,anyone can help thxs
The fact that you can't find the <p> element in your document is actually the problem. The schema expects a Paragraph element in every TableCell; without the Paragraph the document is invalid. This leads to the rather cryptic error that you must have a <p> (open paragraph element) before a </tc> (close table cell element).
Adding a Paragraph to each TableCell you create will solve your problem. The easiest way to do that is to pass a new Paragraph to each TableCell constructor:
string path = #"D:\newdoc.docx";
using (WordprocessingDocument doc = WordprocessingDocument.Create(path, WordprocessingDocumentType.Document))
{
MainDocumentPart mainpart = doc.AddMainDocumentPart();
mainpart.Document = new Document();
Body body = mainpart.Document.AppendChild(new Body());
Table t = new Table();
TableProperties tpr = new TableProperties(new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto }, new TableLook() { Val = "04A0" });
t.Append(tpr);
TableGrid tg = new TableGrid(new GridColumn() { Width = "4261" }, new GridColumn() { Width = "4261" });
t.Append(tg);
TableRow tr1 = new TableRow();
TableCell r1tc1 = new TableCell(new Paragraph());
TableCell r1tc2 = new TableCell(new Paragraph());
tr1.Append(r1tc1);
tr1.Append(r1tc2);
TableRow tr2 = new TableRow();
TableCell r2tc1 = new TableCell(new Paragraph());
TableCell r2tc2 = new TableCell(new Paragraph());
tr2.Append(r2tc1);
tr2.Append(r2tc2);
TableRow tr3 = new TableRow();
TableCell r3tc1 = new TableCell(new Paragraph());
TableCellProperties r3tc1prp = new TableCellProperties();
VerticalMerge vm = new VerticalMerge() { Val = MergedCellValues.Restart };
r3tc1prp.Append(vm);
r3tc1.Append(r3tc1prp);
TableCell r3tc2 = new TableCell(new Paragraph(), new TableCellProperties());
tr3.Append(r3tc1);
tr3.Append(r3tc2);
TableRow tr4 = new TableRow();
TableCell r4tc1 = new TableCell(new Paragraph());
r4tc1.TableCellProperties = new TableCellProperties(new TableCellWidth() { Width = "4261", Type = TableWidthUnitValues.Dxa });
r4tc1.TableCellProperties.VerticalMerge = new VerticalMerge();
TableCell r4tc2 = new TableCell(new Paragraph());
tr4.Append(r4tc1);
tr4.Append(r4tc2);
t.Append(tr1);
t.Append(tr2);
t.Append(tr3);
t.Append(tr4);
body.Append(t);
}

Adding Bin/Lot/Serial item to Acumatica shipment lines

Adding Bin/Lot/Serial item to Acumatica shipment lines
I are able to create an Acumatica shipment through Web Services, but getting an issue in adding Bin/Lot Number for each line in the grid. If I have only one document detail line in shipment, it is working fine, but when there is more than one line in document details, the code does not seem to be working. Please find below the Acumatica code that I am using to achieve this.
SO302000Content soShipcontent = content.SO302000GetSchema();
List<Command> scmds = new List<Command>();
List<LineDetails> splits = new List<LineDetails>();
CreateShipmentHeader(soShipcontent, hparams, ref scmds, Ordernumber);
var shipmentresults = content.SO302000Submit(scmds.ToArray());
if (shipmentresults != null && shipmentresults.Length > 0)
{
int linen = 0;
List<Command> cmds = new List<Command>();
foreach (var row in shipmentresults)
{
SO302000Content c = (SO302000Content)row;
cmds.Add(new Value { Value = linen.ToString(), LinkedCommand = soShipcontent.AddSalesOrder.ServiceCommands.RowNumber });
cmds.Add(new Value { Value = "True", LinkedCommand = soShipcontent.AddSalesOrder.Selected, Commit = true });
LineDetails ld = details.Find(x => x.InventoryId == c.AddSalesOrder.InventoryID.Value.ToString().Trim());
if (ld != null)
{
LineDetails splitno = new LineDetails();
splitno.InventoryId = ld.InventoryId;
splitno.Location = ld.Location;
splitno.LotNo = ld.LotNo;
splitno.Quantity = c.AddSalesOrder.Quantity.Value.ToString().Trim();
splitno.LineNumber = (linen).ToString();
splits.Add(splitno);
}
linen++;
}
cmds.Add(soShipcontent.Actions.AddSO);
content.SO302000Submit(cmds.ToArray());
foreach (LineDetails s in splits)
{
List<Command> cmdsplit = new List<Command>();
cmdsplit.Add(new Value { Value = s.LineNumber, LinkedCommand = soShipcontent.BinLotSerialNumbers.ServiceCommands.RowNumber });
cmdsplit.Add(new Value { Value = s.InventoryId, LinkedCommand = soShipcontent.BinLotSerialNumbers.InventoryID, Commit = true });
cmdsplit.Add(new Value { Value = s.Location, LinkedCommand = soShipcontent.BinLotSerialNumbers.Location, Commit = true });
cmdsplit.Add(new Value { Value = s.LotNo, LinkedCommand = soShipcontent.BinLotSerialNumbers.LotSerialNbr });
cmdsplit.Add(new Value { Value = s.Quantity, LinkedCommand = soShipcontent.BinLotSerialNumbers.Quantity });
content.SO302000Submit(cmdsplit.ToArray());
}
}
List<Command> cmds1 = new List<Command>();
string shipmentnbr = string.Empty;
cmds1.Add(soShipcontent.Actions.Save);
cmds1.Add(soShipcontent.ShipmentSummary.ShipmentNbr);
content.SO302000Submit(cmds1.ToArray());
I have tried below code also:
cmds.Add(soShipcontent.BinLotSerialNumbers.ServiceCommands.NewRow);
cmdsplit.Add(new Value { Value = s.Location, LinkedCommand = soShipcontent.BinLotSerialNumbers.Location});
cmdsplit.Add(new Value { Value = s.LotNo, LinkedCommand = soShipcontent.BinLotSerialNumbers.LotSerialNbr });
cmdsplit.Add(new Value { Value = s.Quantity, LinkedCommand = soShipcontent.BinLotSerialNumbers.Quantity, Commit = true });
cmdsplit.Add(new Value { Value = s.InventoryId, LinkedCommand = soShipcontent.BinLotSerialNumbers.InventoryID });
cmdsplit.Add(new Key { Value = "='" + s.InventoryId + "'", FieldName = soShipcontent.DocumentDetails.InventoryID.FieldName, ObjectName = soShipcontent.DocumentDetails.InventoryID.ObjectName });
Actually i'm not really following your code but i would say that acumatica an assign SN automatically depends on the item settings. Otherwise you can manually assign SN.
The most simplest example is when you have qty = 1 on the detail level, see code below
Content[] result = context.Submit(
new Command[]
{
new Value { Value = "000200", LinkedCommand = SO302000.ShipmentSummary.ShipmentNbr, Commit = true },
//navigate to line
new Key
{
ObjectName = SO302000.DocumentDetails.InventoryID.ObjectName,
FieldName = SO302000.DocumentDetails.InventoryID.FieldName,
Value = "='INCLUTA009'"
},
new Value { Value = "20SP0610", LinkedCommand = SO302000.DocumentDetails.LotSerialNbr, Commit = true },
SO302000.Actions.Save
}
);

alignX isn't working?

Here's my simple code; I'm expecting my atom1 widget (row:0, column:0) to be righ aligned; but can't get it! Any suggestions?
var layout = new qx.ui.layout.Grid();
layout.setRowFlex(0, 1); // make row 0 flexible
layout.setColumnWidth(1, 200); // set with of column 1 to 200 pixel
var container = new qx.ui.container.Composite(layout);
this.getRoot().add(container, {left:200, top:200});
var atom1 = new qx.ui.basic.Atom("Icon Right1", "").set({alignX:'right', alignY:'middle'});
var atom2 = new qx.ui.basic.Atom("Icon Right2", "");
var button1 = new qx.ui.form.Button("First Button", "test/test.png");
container.add(atom1, {row: 0, column: 0});
container.add(atom2, {row: 0, column: 1});
container.add(button1, {row: 1, column: 0});
you have to prevent the atom from growing or it will just fill the cell and have no room to move.
add allowGrowX: false ...
see the qooxdoo playground for an example

Resources