📄 databoundcomponent.js
字号:
if (this.dataSource) { if (this.isA("DynamicForm")) this.setData({}); else this.setData([]); } this.markForRedraw("bind");},// backCompatbind : function (dataSource, fields) { this.setDataSource(dataSource, fields);},getDataSource : function () { if (isc.isA.String(this.dataSource)) { var ds = isc.DS.get(this.dataSource); if (ds != null) return ds; // support "dataSource" being specified as the name of a global, and if so, assign // that to this.dataSource ds = this.getWindow()[this.dataSource]; if (ds && isc.isA.DataSource(ds)) return (this.dataSource = ds); } return this.dataSource;},//>@method DataBoundComponent.fieldValuesAreEqual()// Compares two values and returns true if they are equal. This is used to handle cases// where edited values are equivalent to saved values, but a simple// Javascript comparison (a == b) will return false (for example Date fields).// @param field (object) field to which the values belong// @param value1 (any) first value to be compared// @param value2 (any) second value to be compared// @visibility internal//<// Leave visibility internal, but non obfuscated - we may allow developers to override this for// custom field typesfieldValuesAreEqual : function (field, value1, value2) { // no matter what the type if they are '==' always return true; if (value1 == value2) return true; // If we don't have field object for the value passed in - just rely on the "==" comparison // This typically occurs when we have editValues in a grid, or values in a DynamicForm // that don't have a corresponding field object. if (field == null) return false; if (field.type == "date") { if (isc.isA.Date(value1) && isc.isA.Date(value2)) { return (Date.compareDates(value1, value2) == 0); } } else if (field.type == "valueMap") { if (isc.isAnArray(value1) && isc.isAn.Array(value2)) { return value1.equals(value2) } else if (isc.isAn.Object(value1) && isc.isAn.Object(value2)) { for (var i in value1) { if (value2[i] != value1[i]) return false; } for (var j in value2) { if (value1[j] != value2[j]) return false; } // everything matched return true; } } // return false return false;},//> @attr dataBoundComponent.useFlatFields (boolean : null : IR)// The <code>useFlatFields</code> flag causes all simple type fields anywhere in a nested// set of DataSources to be exposed as a flat list for form binding. // <P>// <code>useFlatFields</code> is typically used with imported metadata, such as // +link{XMLTools.loadXMLSchema,XML Schema} from a // +link{XMLTools.loadWSDL,WSDL-described web servce}, as a means of eliminating levels of XML// nesting that aren't meaningful in a user interface, without the cumbersome and fragile// process of mapping form fields to XML structures.// <P>// For example, having called +link{webService.getInputDS()} to retrieve the input message// schema for a web service operation whose input message looks like this:// <pre>// <FindServices>// <searchFor>search text</searchFor>// <Options>// <caseSensitive>false</caseSensitive>// </Options>// <IncludeInSearch>// <serviceName>true</serviceName>// <documentation>true</documentation>// <keywords>true</keywords>// </IncludeInSearch>// </FindServices>// </pre>// Setting <code>useFlatFields</code> on a +link{DynamicForm} that is bound to this input// message schema would result in 5 +link{FormItem,FormItems} reflecting the 5 simple type// fields in the message.// <P>// For this form, the result of +link{dynamicForm.getValues(),form.getValues()} might look// like:// <P>// <pre>{// searchFor: "search text",// caseSensitive: false,// serviceName: true,// documentation : true,// keywords : true// }</pre>// When contacting a +link{WebService,WSDL web service}, these values can be automatically// mapped to the structure of the input message for a web service operation by setting// +link{wsRequest.useFlatFields} (for use with +link{webService.callOperation()}) or by setting// +link{dsRequest.useFlatFields} (for use with a +link{DataSource} that is// +link{group:wsdlBinding,bound to a WSDL web service} via// +link{operationBinding.wsOperation}). // <P>// Using these two facilities in conjunction (component.useFlatFields and// request.useFlatFields) allows gratuitous nesting to be consistently bypassed in both the user// presentation and in the actual XML messaging.// <P>// You can also set +link{operationBinding.useFlatFields} to automatically enable // "flattened" XML serialization (request.useFlatFields) for all DataSource requests of a// particular operationType.// <P>// Note that <code>useFlatFields</code> is not generally recommended for use with structures// where multiple simple type fields exist with the same name, however if used with such a// structure, the first field to use a given name wins. "first" means the first field// encountered in a depth first search. "wins" means only the first field will be present as a// field when data binding.// // @visibility external//<// minimal implementation of setFields()setFields : function (fields) { // combine specified "fields" with reference declarations in the dataSource fields = this.bindToDataSource(fields); this.fields = fields;},getSerializeableFields : function (removeFields, keepFields) { // data may actually be valid in some cases - but removing it is a good default. removeFields.addList(["zIndex", "data"]); // don't save ID if it's auto-generated if (this.ID && this.ID.startsWith("isc_")) removeFields.add("ID"); // if this component is bound to a datasource, don't serialize its fields or items if (this.dataSource) removeFields.addList(["fields", "items"]); // we only want to serialize children created explicitly by a developer - not children // auto-created by an ISC component (such as the ListGrid header) if (this.getClassName() != "Canvas" && this.getClassName() != "Layout") { removeFields.add("children"); } return this.Super("getSerializeableFields", arguments);},addField : function (field, index) { var fields = (this.fields || this.items || isc._emptyArray).duplicate(); fields.addAt(field, index); this.setFields(fields);},removeField : function (fieldName) { var fields = (this.fields || this.items || isc._emptyArray).duplicate(); fields.remove(fields.find("name", fieldName)); this.setFields(fields);},// DataBound Component Methods// --------------------------------------------------------------------------------------------//> @groupDef dataBoundComponentMethods// An Action Method initiates an orchestrated client-server flow that stores or retrieves data// and updates one or more components.// <P>// For example, the +link{DynamicForm.saveData(),editor.saveData()} Action Method saves the// record currently being edited in the form, transparently handling the trip to the server,// standard error conditions such as validation errors (whether the validation error// happens on the client or server), and update of client-side caches.// <P>// Action Methods are available on DataBoundComponents.//// @treeLocation Client Reference/Data Binding// @see interface:DataBoundComponent// @title DataBound Component Methods// @visibility external//<// NOTE: the DataBound Component Methods are mostly implemented directly on Canvas, and act// as a basic framework for building a DataBound widget, however, we document them as existing// on the specific components where it actually makes sense to call them.//> @method listGrid.fetchData()// @include dataBoundComponent.fetchData()// @group dataBoundComponentMethods// @visibility external// @example databoundFetch//<//> @attr listGrid.autoFetchData (boolean : false : IR)// @include dataBoundComponent.autoFetchData// @group databinding// @visibility external// @example fetchOperation//<//> @attr listGrid.initialCriteria (Criteria : null :IR)// @include dataBoundComponent.initialCriteria// @visibility external//<//> @method listGrid.filterData()// @include dataBoundComponent.filterData()// @group dataBoundComponentMethods// @visibility external// @example databoundFilter//<//> @method listGrid.fetchRelatedData()// @include dataBoundComponent.fetchRelatedData()// @group dataBoundComponentMethods// @visibility external//<//> @method listGrid.clearCriteria()// @include dataBoundComponent.clearCriteria()// @group dataBoundComponentMethods// @visibility external// @example databoundFilter//<//> @method listGrid.addData()// @include dataBoundComponent.addData()// @group dataBoundComponentMethods// @visibility external// @example databoundAdd//<//> @method listGrid.updateData()// @include dataBoundComponent.updateData()// @group dataBoundComponentMethods// @visibility external// @example databoundUpdate//<//> @method listGrid.removeData()// @include dataBoundComponent.removeData()// @group dataBoundComponentMethods// @visibility external// @example databoundRemove//<//> @method listGrid.removeSelectedData()// @include dataBoundComponent.removeSelectedData()// @group dataBoundComponentMethods// @visibility external// @example removeOperation//< //> @method listGrid.getSelection()// @include dataBoundComponent.getSelection()//// @group selection// @visibility external// @example databoundRemove//<//> @method listGrid.getSelectedRecord()// Return the first selected record in this component.<br><br>// This method is appropriate if <code>+link{attr:listGrid.selectionType}</code> is// <code>"single"</code>, or if you only care about the first selected record in// a multiple-record selection. To access all selected records, use// <code>+link{method:listGrid.getSelection()}</code> instead.// @group selection// @return (ListGridRecord) first selected record, or null if nothing selected// @visibility external// @example databoundRemove//<//> @method treeGrid.fetchData()// Uses a "fetch" operation on the current +link{DataSource,grid.dataSource} to retrieve data// that matches the provided criteria, and displays the matching data in this component as a// tree.// <P>// This method will create a +link{ResultTree} to manage tree data, which will// subsequently be available as <code>treeGrid.data</code>. DataSource records// returned by the "fetch" operation are linked into a tree structure according to// +link{dataSourceField.primaryKey,primaryKey} and// +link{dataSourceField.foreignKey,foreignKey} declarations on DataSource fields. See the// +link{group:treeDataBinding} topic for complete details.// <P>// By default, the created ResultTree will use folder-by-folder load on demand, asking the// server for the children of each folder as the user opens it.// <P>// The +link{ResultTree} created by <code>fetchData()</code> can be customized by setting// +link{listGrid.dataProperties} to an Object containing properties and methods to apply to// the created ResultTree. For example, the property that determines whether a node is a// folder (+link{Tree.isFolderProperty,isFolderProperty}) can be customized, or// level-by-level loading can be disabled via// +link{resultTree.loadDataOnDemand,loadDataOnDemand:false}.// <P>// The callback passed to <code>fetchData</code> will fire once, the first time that data is// loaded from the server. If using folder-by-folder load on demand, use the// +link{resultTree.dataArrived()} notification to be notified each time new nodes are loaded.// <P>// Note that, if criteria are passed to <code>fetchData()</code>, they will be passed every// time a new "fetch" operation is sent to the server. This allows you to retrieve multiple// different tree structures from the same DataSource. However note that the server is expected// to always respond with an intact tree - returned nodes which do not have parents are dropped// from the dataset and not displayed.//// @include dataBoundComponent.fetchData()// @group dataBoundComponentMethods// @visibility external//<//> @method treeGrid.filterData()// Retrieves data that matches the provided criteria and displays the matching data in this// component.// <P>// This method behaves exactly like +link{treeGrid.fetchData()} except that// +link{dsRequest.textMatchStyle} is automatically set to "substring" so that String-valued// fields are matched by case-insensitive substring comparison.//// @include dataBoundComponent.filterData()// @group dataBoundComponentMethods// @visibility external//<//> @attr dynamicForm.autoFetchData (boolean : false : IR)// @include dataBoundComponent.autoFetchData// @group databinding// @visibility external//<//> @attr dynamicForm.initialCriteria (Criteria : null :IR)// @include dataBoundComponent.initialCriteria// @visibility external//<// Filtering// -----------------------------------------------------------------------------//> @method dataBoundComponent.filterData()// Retrieves data that matches the provided criteria and displays the matching data in this// component.// <P>// This method behaves exactly like +link{listGrid.fetchData()} except that// +link{dsRequest.textMatchStyle} is automatically set to "substring" so that String-valued// fields are matched by case-insensitive substring comparison.//// @param [criteria] (Criteria) Search criteria. // If a +link{DynamicForm} is passed in as this argument// instead of a raw criteria object, will be derived by calling// +link{DynamicForm.getValuesAsCriteria()}// @param [callback] (DSCallback) callback to invoke on completion// @param [requestProperties] (DSRequest) for databound components only - optional // additional properties to set on the DSRequest that will be issued//// @group dataBoundComponentMethods// @visibility internal//<filterData : function (criteria, callback, requestProperties) { this._filter("filter", criteria, callback, requestProperties);},//> @method dataBoundComponent.fetchData()// Uses a "fetch" operation on the current +link{DataSource,grid.dataSource} to retrieve data
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -