рамка и цвет для таблицы прокрутки заголовка - PullRequest
0 голосов
/ 20 марта 2020

Ниже приведен блок кода, в который я также включил ожидаемые и фактические изображения ниже. Я также прошел через это https://forum.nwoods.com/t/scrolling-table/9707/5, но не смог правильно следовать.

  const $ = GraphObject.make;  // for conciseness in defining templates
  this.loadScrollingTable();
  // This is the function with the ScrollingTable.js code

  this.diagram =
    $(go.Diagram, "myDiagramDiv",
      {
        "PartResized": function(e) {
          var node = e.subject;
          var scroller = node.findObject("SCROLLER");
          if (scroller !== null) scroller._updateScrollBar(scroller.findObject("TABLE"));
        },
        initialDocumentSpot: Spot.Center,
        initialViewportSpot: Spot.Center,
        initialAutoScale: Diagram.Uniform,
        validCycle: Diagram.CycleNotDirected,  // don't allow loops
        'undoManager.isEnabled': true
      });

      // function BindSelection(name, yes, no) {
      //   return new go.Binding(name, "isSelected", function(s) { return s ? yes : no; }).ofObject();
      // }


      this.diagram.nodeTemplate =
      $(go.Node, "Vertical",
      {
        selectionObjectName: "SCROLLER",
        resizable: true, resizeObjectName: "SCROLLER",
        portSpreading: go.Node.SpreadingNone
      },
      new go.Binding("location").makeTwoWay(),
      $(go.TextBlock,
        { font: "bold 14px sans-serif" },
        new go.Binding("text", "key")),
        $(go.Panel, "Auto",
        $(go.Shape, { fill: "white" }),
        // $("TreeExpanderButton",
        // { alignment: go.Spot.Bottom, alignmentFocus: go.Spot.Top },
        // { visible: true }),
        $("ScrollingTable",
        {
          name: "SCROLLER",
          desiredSize: new go.Size(NaN, 60),  // fixed width
          stretch: go.GraphObject.Fill,       // but stretches vertically
          defaultColumnSeparatorStroke: "gray",
          defaultColumnSeparatorStrokeWidth: 0.5
        },
          $("TreeExpanderButton",
          { alignment: go.Spot.Top, alignmentFocus: go.Spot.Top, visible: true}),      
          new go.Binding("TABLE.itemArray", "items"),
          new go.Binding("TABLE.column", "left", function(left) { return left ? 2 : 0; }),
          new go.Binding("desiredSize", "size").makeTwoWay(),
          {
            "TABLE.itemTemplate":
              $(go.Panel, "TableRow",
              {
                  defaultStretch: go.GraphObject.Horizontal,
                  fromLinkable: true, toLinkable: true,
                },
                new go.Binding("portId", "name"),
                $(go.TextBlock, { column: 0 }, new go.Binding("text", "name")),
                $(go.TextBlock, { column: 1 }, new go.Binding("text", "value"))
                ),
                "TABLE.defaultColumnSeparatorStroke": "gray",
                "TABLE.defaultColumnSeparatorStrokeWidth": 0.5,
                "TABLE.defaultRowSeparatorStroke": "gray",
                "TABLE.defaultRowSeparatorStrokeWidth": 0.5,
                "TABLE.defaultSeparatorPadding": new go.Margin(1, 3, 0, 3)
              }
              )
              )
              );

              this.diagram.linkTemplate =
                  $("Link",
                  { routing: go.Link.Orthogonal,  // Orthogonal routing
                    // corner: 10,                 // with rounded corners    
                    relinkableFrom: true, relinkableTo: true, toShortLength: 2},
                   {cursor:"pointer"},
                    $("Shape", { stroke: "#2E68CC", strokeWidth: 2 }),
                    $("Shape", { fill: "#2E68CC", stroke: null, toArrow: "Standard" }),
                    // $(go.Panel, "Auto",
                    //   { margin: 3 },
                    //   $("Button",
                    //   { margin: 2,
                    //     click: this.resJson() })));
                    // $(go.Shape, { strokeWidth: 2 },
                    //   BindSelection("stroke", "dodgerblue", "black")),
                    $(go.TextBlock,
                      { visible:true, editable: true, textAlign: 'center', font: '14px Roboto', segmentOffset: new go.Point(0, -10),
                      segmentOrientation: go.Link.OrientUpright  },
                      new go.Binding("text", "text").makeTwoWay())
                      // BindSelection("stroke", "white", "black"),
                      //   BindSelection("background", "dodgerblue", null)),
                      // $(go.Shape, { toArrow: 'Triangle', scale: 2, strokeWidth: 0 },
                      //   BindSelection("fill", "dodgerblue", "black"))
                  );

              this.diagram.layout = $(go.TreeLayout);

  this.diagram.model = $(go.GraphLinksModel,
    {
      linkFromPortIdProperty: "fromPort",
      linkToPortIdProperty: "toPort",
      nodeDataArray: this.dataArray,
      linkDataArray: this.linkArray
    });
    const tempfromnode =
    $(Node,
        { layerName: 'Tool' },
        $(Shape, 'Rectangle',
            {
                stroke: '#009fe3', strokeWidth: 3, fill: null,
                portId: '', width: 1, height: 1
            })
    );
const temptonode =
    $(Node,
        { layerName: 'Tool' },
        $(Shape, 'Rectangle',
            {
                stroke: '#009fe3', strokeWidth: 3, fill: null,
                portId: '', width: 1, height: 1
            })
    );

this.diagram.toolManager.linkingTool.temporaryFromNode = tempfromnode;
this.diagram.toolManager.linkingTool.temporaryFromPort = tempfromnode.port;
this.diagram.toolManager.linkingTool.temporaryToNode = temptonode;
this.diagram.toolManager.linkingTool.temporaryToPort = temptonode.port;
this.diagram.toolManager.relinkingTool.temporaryFromNode = tempfromnode;
this.diagram.toolManager.relinkingTool.temporaryFromPort = tempfromnode.port;
this.diagram.toolManager.relinkingTool.temporaryToNode = temptonode;
this.diagram.toolManager.relinkingTool.temporaryToPort = temptonode.port;

this.diagram.toolManager.linkingTool.temporaryLink =
    $(Link,
        { layerName: 'Tool' },
        $(Shape,
            { stroke: '#646363', strokeWidth: 2 })
    );
}

Я не могу добавить границу в заголовок таблицы прокрутки, ниже приведены текущие и ожидаемые изображения. А также я добавил блок кода. https://gojs.net/latest/extensions/scrollingTable.html

enter image description here enter image description here

1 Ответ

0 голосов
/ 22 марта 2020

Просто поместите границу вокруг этого простого TextBlock и убедитесь, что он растягивается горизонтально, чтобы иметь такую ​​же ширину, как и остальная часть узла.

      myDiagram.nodeTemplate =
        $(go.Node, "Vertical",
          { . . . },
          new go.Binding("location").makeTwoWay(),
          $(go.Panel, "Auto",
            { stretch: go.GraphObject.Horizontal },
            $(go.Shape, { fill: "aqua", strokeWidth: 3 }),
            $(go.TextBlock,
              { margin: 3, font: "bold 14px sans-serif" },
              new go.Binding("text", "key"))
          ),
          . . .
...