[]
Sheets.Bindings.CellBindingSource
• new CellBindingSource(source, activeRecordIndex?)
Represents a source for cell binding.
example
// Bind a normal data source.
var person = { name: "Wang feng", age: 25, address: { postcode: "710075" } };
var source = new GC.Spread.Sheets.Bindings.CellBindingSource(person);
activeSheet.setBindingPath(0, 0, "name");
activeSheet.setBindingPath(1, 1, "age");
activeSheet.setBindingPath(3, 3, "address.postcode");
activeSheet.setDataSource(source);
// Bind a Data Manager table.
var personsTable = dataManager.addTable("persons", {
data: [person]
});
var source = new GC.Spread.Sheets.Bindings.CellBindingSource(personsTable);
activeSheet.setBindingPath(0, 0, "name");
activeSheet.setBindingPath(1, 1, "age");
activeSheet.setBindingPath(3, 3, "address.postcode");
activeSheet.setDataSource(source);
| Name | Type | Description |
|---|---|---|
source |
string | Object | Table |
The data source, a Data Manager table, or a Data Manager table name. |
activeRecordIndex? |
number |
The active record index for the current cell binding source. The default value is 0. |
▸ activeRecordIndex(index?): number
Gets or sets the active record index for the current cell binding source.
example
// This example sets the active record index.
var personsTable = dataManager.addTable("persons", {
data: [
{ name: "Wang feng", age: 25, address: { postcode: "710075" } },
{ name: "Li lei", age: 26, address: { postcode: "710076" } }
]
});
var source = new GC.Spread.Sheets.Bindings.CellBindingSource(personsTable, 1);
activeSheet.setDataSource(source);
activeSheet.setBindingPath(0, 0, "name");
alert(source.activeRecordIndex());
source.activeRecordIndex(0);
| Name | Type | Description |
|---|---|---|
index? |
number |
The active record index. |
number
The active record index.
▸ getSource(): Object
Gets the source information for cell binding.
example
//This example gets the name.
var person = { name: "Wang feng", age: 25, address: { postcode: "710075" } };
var source = new GC.Spread.Sheets.Bindings.CellBindingSource(person);
activeSheet.setBindingPath(0, 0, "name");
activeSheet.setBindingPath(1, 1, "age");
activeSheet.setBindingPath(3, 3, "address.postcode");
activeSheet.setDataSource(source);
alert(source.getSource().name);
//This example gets the source information for a Data Manager table.
var personsTable = dataManager.addTable("persons", {
data: [person]
});
var dataManagerSource = new GC.Spread.Sheets.Bindings.CellBindingSource(personsTable, 1);
var sourceInfo = dataManagerSource.getSource();
alert(sourceInfo.tableName);
alert(sourceInfo.activeRecordIndex);
Object
If the source is a Data Manager source, returns an object that contains the table name and active record index; otherwise, returns the wrapped source.
▸ getValue(path): Object
Gets the value of the source by the binding path.
example
//This example gets the value.
var person = {name: "Wang feng", age: 25, address: {postcode: "710075"}};
var source = new GC.Spread.Sheets.Bindings.CellBindingSource(person);
activeSheet.setBindingPath(0, 0, "name");
activeSheet.setBindingPath(1, 1, "age");
activeSheet.setBindingPath(3, 3, "address.postcode");
activeSheet.setDataSource(source);
alert(source.getValue("name"));
| Name | Type | Description |
|---|---|---|
path |
string |
The binding path. |
Object
Returns the value of the binding source at the specified path.
▸ setValue(path, value): void
Sets the value of the source by the binding path.
example
//This example sets the name value.
var person = {name: "Wang feng", age: 25, address: {postcode: "710075"}};
var source = new GC.Spread.Sheets.Bindings.CellBindingSource(person);
activeSheet.setBindingPath(0, 0, "name");
activeSheet.setBindingPath(1, 1, "age");
activeSheet.setBindingPath(3, 3, "address.postcode");
activeSheet.setDataSource(source);
source.setValue("name", "test");
activeSheet.resumePaint();
activeSheet.repaint();
| Name | Type | Description |
|---|---|---|
path |
string |
The row index. |
value |
Object |
The value to set. |
void