Create New Grid

This script creates a new grid view.

Defaults for this script are set for the Pubchem demo data tree in the sample project included in IJC.

import com.chemaxon.ijc.form.api.*
import com.chemaxon.ijc.form.api.renderers.*
import com.chemaxon.ijc.commons.datarequest.api.FieldReference

ety = dataTree.rootVertex.entity

// Main script body
grid = new Grid(createTableWidget())
DFViews.create(dataTree, grid, "Sample grid")


// create table widget
def createTableWidget() {
table = new TableWidget()
table.setRowHeight(100)
table.setHeaderRows(2)
Border border = new Border()
border.setBorderType(Border.BorderType.EMPTY)
table.setBorder(border)

table.addColumn(newFieldReference("Structure"), new StructureRenderer())
table.addColumn(newFieldReference("CdId"), new IntegerRenderer())
table.addColumn(newFieldReference("Mol Weight"), new FloatRenderer())
table.addColumn(newFieldReference("Formula"), new TextRenderer())
table.addColumn(newFieldReference("IUPAC name"), new MultiLineTextRenderer())
table.addColumn(newFieldReference("Donors"), new IntegerRenderer())
table.addColumn(newFieldReference("Acceptors"), new IntegerRenderer())
table.addColumn(newFieldReference("Rot bonds"), new IntegerRenderer())
table.addColumn(newFieldReference("DB regid"), new MultiLineTextRenderer())
table.addColumn(newFieldReference("DB name"), new TextRenderer())
table.addColumn(newFieldReference("XLogP"), new FloatRenderer())

return table
}

def newFieldReference(name) {
field = ety.fields.items.find { it.name == name }
new FieldReference(ety.id, field.id)
}

Versions: This script has been tested on IJC version 6.1. This script will not work in IJC versions prior 6.1.

Copyright © 1999-2012 ChemAxon Ltd.    All rights reserved.