Swift:Shinobi Grid中的自动文本

时间:2017-05-09 01:28:00

标签: swift datagrid shinobi

我正在使用Shinobi数据网格,但是我遇到了一些问题,因为很难找到关于Shinobi Grid的Swift示例或问题。在我的代码段下面:

    var grid: ShinobiDataGrid?

    grid = ShinobiDataGrid(frame: self.view.bounds)
    grid?.frame = CGRect(x: 0, y: 120, width: (screenWidth), height: 600)

    theme = SDataGridTheme()
    theme?.iOS7Arrows = true
    theme?.hideVerticalGridlines = false
    grid?.apply(theme)

    self.view.addSubview(grid!) 
    .........

   addColumn(grid!, title: "Floor", width: 100, alignment: .right, alignmentHeader: .right)

    grid?.numberOfFrozenColumns = 2
    grid?.layer.borderWidth = 1

    grid?.defaultCellStyleForHeaderRow.backgroundColor = UIColor(hex: "#1A237E")
    grid?.defaultCellStyleForHeaderRow.textColor = UIColor.white
    grid?.defaultCellStyleForHeaderRow.font.withSize(5)

    grid?.dataSource = self
    grid?.delegate = self
    ........

   func shinobiDataGrid(_ grid: ShinobiDataGrid!, prepareCellForDisplay cell: SDataGridCell!) {
    let textCell = cell as! SDataGridTextCell

     //        let textCell = cell as! SDataGridMultiLineTextCell
    var dataRow: [AnyHashable: Any]?

    dataRow = filteredDataRoomingList?[cell.coordinate.row.rowIndex] as? [AnyHashable: Any]

    textCell.sizeToFit()

    if (searchBarActive) {
        dataRow = filteredSearchDataRoomingList?[cell.coordinate.row.rowIndex] as? [AnyHashable: Any]
    }
    else {
       dataRow = filteredDataRoomingList?[cell.coordinate.row.rowIndex] as? [AnyHashable: Any]
    }

    if textCell.coordinate.column.tag == 0 {
        textCell.textField.text = (String(dataRow?["floor"] as! Int))
    //            gridMultiLine.textLabel.text = (String(dataRow?["floor"] as! Int))

           }
   }

我希望我的单元格在其内容中显示全文(换行内容),而不是用....截断文本。

我读过this,但我不知道这个块,因为它在Objective C:

SDataGridColumn *nameColumn = [[SDataGridColumn alloc] initWithTitle:@"Forename" cellType:[SDataGridMultiLineTextCell class]];
nameColumn.editable = YES;
nameColumn.width = @250;
[self.shinobiDataGrid addColumn:nameColumn];

任何建议和答案对我都有帮助。提前致谢

1 个答案:

答案 0 :(得分:0)

我在代码下面创建here的函数库:

prepareCellForDisplay

dataSource func shinobiDataGrid(_ grid: ShinobiDataGrid!, prepareCellForDisplay cell: SDataGridCell!) { let dataCell = cell as! SDataGridMultiLineTextCell if cell.coordinate.column.tag == 0 { dataCell.sizeToFit() dataCell.textLabel.text = "msadimfodvnuonvosvndvdivndlvsndvmvnlcvnoidn odnosdvk odkmvosdk sodimdokvs kmdsdokv " } if cell.coordinate.column.tag == 1 { dataCell.sizeToFit() dataCell.textLabel.text = "msadimfodvnuonvosvndvdivndlvsndvmvnlcvnoidn odnosdvk odkmvosdk sodimdokvs kmdsdokv sdmfdfkm sdlfkdmlf dosfod domdso os " } } 变成了这样:

(defun gen-seq (from to sep)
  "Generates sequence of numbers FROM .. TO with separator SEP"
  (interactive "nFrom: \nnTo: \nMSeparator: ")
  (let* ((sepesc (replace-regexp-in-string "\"" "\\\\\"" sep))
         (sepnew (car (read-from-string (concat "\"" sepesc "\"")))))
    (insert (mapconcat 'number-to-string (number-sequence from to) sepnew))))

this