diff --git a/README.md b/README.md index e9290d8..4664ee9 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ All features can be seen in action in the test/demo project. ## Backlog -- Currently only XPath can be used to get the grid data. Datasource microflows will be supported in a future release. +- Currently only XPath can be used to get the grid data. ## Configuration @@ -131,6 +131,7 @@ The widget does not display search filter inputs. To provide search filters, def __Filtering on booleans.__ Filtering on booleans is a little tricky because there is no way to tell the difference between off/false or no selection made. To overcome this, the widget expects an enumeration as attribute on your context entity. The modeler does not allow the value _true_ for an enumeration. For the true value, use enumeration value ___t___. For the false value, anything else, but ___f___ would be a good one. The caption can be any value. - _Context entity attribute_ - The attribute on the context entity to get the filter value. +- _Reference name_ - Optional. Reference name (module.refname) to search on an attribute in a referenced entity, can be multiple levels deep. - _Attribute name_ - Attribute name to filter on, this is case sensitive. - _Operator_ - Operator to use. For booleans and enumerations, only _Equals_ makes sense. @@ -242,4 +243,5 @@ Please be sure to turn on the apply entity access setting on your export microfl ### Advanced -- _Placement delay_ - Delay (ms) before placing or moving buttons. Depending on complexity of the page, browsers may need more time to properly render the buttons. \ No newline at end of file +- _Placement delay_ - Delay (ms) before placing or moving buttons. Depending on complexity of the page, browsers may need more time to properly render the buttons. +- _Scroll multiplier_ - Scroll buffer multiplier. This value determines how much data is pre-fetched when infinite scroll is used. Lower values cause less data to be requested from the server but will require more server calls when the user keeps scrolling. \ No newline at end of file diff --git a/src/DataTables/DataTables.xml b/src/DataTables/DataTables.xml index 12aa217..e778466 100644 --- a/src/DataTables/DataTables.xml +++ b/src/DataTables/DataTables.xml @@ -210,6 +210,11 @@ Greater than + + Reference name + Search + Optional. Reference name (module.refname) to search on an attribute in a referenced entity, can be multiple levels deep. + @@ -553,6 +558,12 @@ Delay (ms) before placing or moving buttons. Depending on complexity of the page, browsers may need more time to properly render the buttons. + + Scroll multiplier + Advanced + Scroll buffer multiplier. This value determines how much data is pre-fetched when infinite scroll is used. Lower values cause less data to be requested from the server but will require more server calls when the user keeps scrolling. + + diff --git a/src/DataTables/widget/DataTables.js b/src/DataTables/widget/DataTables.js index af1b488..5a6c9ab 100644 --- a/src/DataTables/widget/DataTables.js +++ b/src/DataTables/widget/DataTables.js @@ -93,6 +93,7 @@ define([ refSearchFilterList: null, buttonDefinitionList: null, buttonPlacementDelay: 0, + scrollBufferMultiplier: 9, allowExport: false, exportButtonCaption: "", exportVisibleColumnsOnly: true, @@ -387,6 +388,8 @@ define([ // Override so start position and search data are not saved. dataTablesOptions.stateSaveParams = function (settings, data) { data.start = 0; + data.iScroller = 0; + data.iScrollerTopRow = 0; data.search.search = ""; }; @@ -403,7 +406,8 @@ define([ if (this.infiniteScroll) { // for normal paging, show the page length drop down. dataTablesOptions.scroller = { - loadingIndicator: true + loadingIndicator: true, + displayBuffer: this.scrollBufferMultiplier }; } @@ -892,7 +896,7 @@ define([ } dojoArray.forEach(this.attrSearchFilterList, function (searchFilter, i) { - var constraintValue = this._getConstraintValue(searchFilter.contextEntityAttr, searchFilter.attrName); + var constraintValue = this._getConstraintValue(searchFilter.contextEntityAttr, searchFilter.attrName, searchFilter.refName); if (constraintValue) { if (hasConstraint) { xpath += " and "; @@ -900,6 +904,9 @@ define([ xpath += "["; } hasConstraint = true; + if (searchFilter.refName) { + xpath += searchFilter.refName + "["; + } switch (searchFilter.operatorType) { case "st": xpath += "starts-with(" + searchFilter.attrName + ", " + constraintValue + ")"; @@ -928,6 +935,9 @@ define([ default: xpath += searchFilter.attrName + " = " + constraintValue; } + if (searchFilter.refName) { + xpath += "]"; + } } }, this); @@ -1099,23 +1109,36 @@ define([ /** * Get the attribute value for use as constraint value * - * @param attrName The attribute name - * @returns {string} The value */ - _getConstraintValue : function (contextEntityAttr, attrName) { + _getConstraintValue : function (contextEntityAttr, attrName, refName) { var attrType, attrValue, dateFormat, + refEntity, + refMetaData, result; if (!this._contextObjMetaData.has(contextEntityAttr)) { logger.error(this._contextObj.getEntity() + " does not have attribute " + contextEntityAttr); return null; } - if (!this._entityMetaData.has(attrName)) { - logger.error(this._contextObj.getEntity() + " does not have attribute " + attrName); - return null; + if (refName) { + refEntity = refName.substring(refName.lastIndexOf("/") + 1); + refMetaData = mx.meta.getEntity(refEntity); + if (!refMetaData) { + logger.error("No meta data found for entity " + refEntity); + return null; + } + if (!refMetaData.has(attrName)) { + logger.error(refEntity + " does not have attribute " + attrName); + return null; + } + } else { + if (!this._entityMetaData.has(attrName)) { + logger.error(this.tableEntity + " does not have attribute " + attrName); + return null; + } } attrValue = this._contextObj.get(contextEntityAttr); @@ -1125,7 +1148,11 @@ define([ } // Use the type of the grid entity attribute. Important for boolean because the context entity attribute will be an enum. - attrType = this._entityMetaData.getAttributeType(attrName); + if (refName) { + attrType = refMetaData.getAttributeType(attrName); + } else { + attrType = this._entityMetaData.getAttributeType(attrName); + } switch (attrType) { case "String": diff --git a/test/DataTablesTest.mpr b/test/DataTablesTest.mpr index a0bae99..1c18be0 100644 Binary files a/test/DataTablesTest.mpr and b/test/DataTablesTest.mpr differ diff --git a/test/javasource/datatablestestmodule/proxies/DataTableContextEntity.java b/test/javasource/datatablestestmodule/proxies/DataTableContextEntity.java index f25dcf1..d51eced 100644 --- a/test/javasource/datatablestestmodule/proxies/DataTableContextEntity.java +++ b/test/javasource/datatablestestmodule/proxies/DataTableContextEntity.java @@ -35,6 +35,7 @@ public enum MemberNames DateValue("DateValue"), DecimalValue("DecimalValue"), BooleanFilter("BooleanFilter"), + CountryCode("CountryCode"), ExportConfig("ExportConfig"), ExportXPath("ExportXPath"), DataTableContextEntity_Person_Current("DataTablesTestModule.DataTableContextEntity_Person_Current"), @@ -574,6 +575,42 @@ public final void setBooleanFilter(com.mendix.systemwideinterfaces.core.IContext getMendixObject().setValue(context, MemberNames.BooleanFilter.toString(), null); } + /** + * @return value of CountryCode + */ + public final java.lang.String getCountryCode() + { + return getCountryCode(getContext()); + } + + /** + * @param context + * @return value of CountryCode + */ + public final java.lang.String getCountryCode(com.mendix.systemwideinterfaces.core.IContext context) + { + return (java.lang.String) getMendixObject().getValue(context, MemberNames.CountryCode.toString()); + } + + /** + * Set value of CountryCode + * @param countrycode + */ + public final void setCountryCode(java.lang.String countrycode) + { + setCountryCode(getContext(), countrycode); + } + + /** + * Set value of CountryCode + * @param context + * @param countrycode + */ + public final void setCountryCode(com.mendix.systemwideinterfaces.core.IContext context, java.lang.String countrycode) + { + getMendixObject().setValue(context, MemberNames.CountryCode.toString(), countrycode); + } + /** * @return value of ExportConfig */ diff --git a/test/widgets/DataTables.mpk b/test/widgets/DataTables.mpk index f5034df..71e5a53 100644 Binary files a/test/widgets/DataTables.mpk and b/test/widgets/DataTables.mpk differ