Skip to content
Roberto Prevato edited this page May 11, 2017 · 9 revisions

This page describes all exception raised by KingTable library. Exceptions thrown by KingTable library contain a link to this page. This approach allows to provide a better description and detailed instructions written comfortably in the GitHub wiki.

1

Missing implementation of Promise. The KingTable library requires either the ES6 Promise objects to be implemented by the browser, or a polyfill to be loaded.

How to resolve: For browsers that do not implement native Promise objects yet, download a ES6 compatible polyfill. The KingTable library has been tested with: https://github.com/stefanpenner/es6-promise.

Example of fallback:

  <script>
    (function () {
      if (!window.Promise) {
        var head = document.getElementsByTagName("head")[0];
        var a = document.createElement("script");
        a.type = "text/javascript";
        a.src = "scripts/libs/polyfills/es6-promise.min.js";
        head.appendChild(a);
      }
    })();
  </script>

2

Missing dependency. This error indicates a missing external dependency.

How to resolve: Make sure that required dependencies to run the code that is causing the problem are loaded. For example: export to Excel plugin may complain about missing js-xlsx library.

3

KingTable initialization error: data is not an array. The KingTable was initialized with a data option, but this is not an instance of Array.

How to resolve: When instantiating a KingTable passing a collection (fixed table), data must be an array of items to be displayed.

4

Cannot determine id property of displayed objects.

How to resolve: Specify the name of the property that is used to identify the table items, using the getIdProperty option.

  // among the options parameter of KingTable constructor:
  getIdProperty: function () {
    return "name_of_property";
  }

5

An AJAX request is required to fetch table items, but url is not configured.

How to resolve: When instantiating the KingTable, specify the url option (url from which items must be fetched, default by HTTP POST request).

Example:

   url: "/api/v1/employees"

6

Returned object is not a catalog. The response object returned by resolution of getFetchPromise Promise (an AJAX call by default) is not in a shape handled by KingTable library. When receiving an AJAX response, it expects either an array of items (fixed mode), or an object with the following structure:

{
  items: [array], // array of items that respect the given filters (set of paginated results)
  total: [number] // the total count of items that respect the given filters, except pagination
}

How to resolve: When returning a paginated set of results using AJAX, server side code should return a JSON object with this structure: { "items": Array, "total": Number }.

7

Missing total items count in response object. The response object returned by resolution of getFetchPromise Promise (an AJAX call by default) is not in a shape handled by KingTable library. When receiving an AJAX response, it expects either an array of items (fixed mode), or an object with the following structure:

{
  items: [array], // array of items that respect the given filters (set of paginated results)
  total: [number] // the total count of items that respect the given filters, except pagination
}

This exception can be thrown also if "total" returned by server is not a number (for example, if it is a string).

How to resolve: When returning a paginated set of results using AJAX, make sure that response object contains the total number of items, in a "total" property, as integer number.

8

Missing view configuration: builder option is undefined or falsy.

How to resolve: Make sure that the table builder option is a valid string, matching one of configured KingTable.builders.

9

Missing views configuration: KingTable.builders is undefined or falsy.

How to resolve: Make sure that the KingTable.builders property is not altered.

10

Missing view handler: configured builder option does not match any value in KingTable.builders.

How to resolve: Make sure that the table builder option matches the name of a builder in KingTable.builders.

11

Missing search properties. A text search must be performed, but there is no information about what properties should be searched (array of strings). For example this may happen if getSearchProperties table function is overridden and it's not returning an array of strings.

How to resolve: Make sure that the array of properties names are fed to the FiltersManager. Check table getSearchProperties function.

12

LiveFilter feature not implemented.

How to resolve: No action; avoid to call setLiveFilter function.

13

getTableData function was specified, but it is not returning a Promise or Promise-like object.

How to resolve: Edit the getTableData function to return a Promise, or a compatible object. For example:

  getTableData: function() {
    return new Promise(function (resolve, reject) {
      // TODO: implement your logic to fetch table specific data (an AJAX request?)
      resolve({
        types: ["A", "B", "C", "D", "E"],
        statuses: ["1", "2", "3", "4", "5"]
      })
    });
  }

14

getFetchPromise did not return a value when resolving. The promise returned by getFetchPromise was resolved, but without any object.

How to resolve: When resolving the promise returned by getFetchPromise function, pass an array of results or a catalog object.

15

Missing regional. The lang table option does not match any regional definition inside KingTable.regional object.

How to resolve: Make sure that the lang table option is a string matching the name of a property inside KingTable.regional object. See documentation on how to implement localization.

16

Invalid columns option.

How to resolve: Make sure that the columns table option is either an object with properties matching the name of items properties, or an array of objects.

17

Missing name in column option. The columns table option was defined as an array of objects. At least one of these objects doesn't have a 'name' property.

How to resolve: When using a columns option in the shape of an array, make sure that all its items have a name property.

18

Column name defined in options, not found inside data items. A column name was defined inside columns option, but was not found inside results items.

How to resolve: Make sure that the columns option is compatible with the structure of items fed to the table.

19

Column does not exist. A column name was used for a function, but the column is not found among table columns.

How to resolve: Make sure to call the function that is throwing exception with names of columns that exist in the table.

20

Missing columns information (properties not initialized). A function was called when the table columns were not initialized, yet; and that function requires columns information.

How to resolve: Make sure to call the function that is throwing exception when columns information are available for the table.

21

Missing view configuration for Rich HTML builder. A view option for the Rich HTML builder is not a string.

How to resolve: Make sure that view option for the table (propagated to its Rich HTML builder) is a string that matches the name of one of the items in Rich HTML builder views option.

22

Missing view resolver for Rich HTML builder. The view option of the Rich HTML builder does not match the name of an object defined in views option.

How to resolve: Make sure that view option for the table (propagated to its Rich HTML builder) is a string that matches the name of one of the items in Rich HTML builder views option.

23

Invalid resolver for Rich HTML builder view. The resolver property of the configured view must either be an object with buildView function; or an instantiable object whose prototype contains a buildView function. Such function is called with table, data and columns parameters.

  view: "foo",
  views: [
    {name:"gallery", resolver: KingTableRhGalleryViewResolver},
    {name:"foo", resolver: FooViewResolver}
  ],

How to resolve: Make sure that resolver object of a configured view implements a buildView function.

24

Invalid html option for column (property). The html option of a column must be a function. Such function receives an item as input and must return an HTML fragment.

How to resolve: Make sure that html option of a column is a function.

25

Cannot display a built table, because the table is not bound to an element.

How to resolve: Make sure that the table is bound to an HTML element.

Example:

  var table = new KingTable({
    element: document.getElementById("container")
  })

26

Cannot update without root element. One of the update view methods of the Rich HTML builder was called, but its rootElement is not configured, yet (it was never rendered before).

How to resolve: Make sure that update view functions are called after the first render.

27

Invalid method definition: it must be either a string or a function. When defining custom events for a table, make sure that they are defined like in below example:

  events: {
    "click .foo-btn": function (e, item) {
      //
    },
    // or...
    "click .foo-btn": "fooHandler" // <-- functionName must be defined in options or in the table itself
  },
  fooHandler: function (e, item) {}

How to resolve: Make sure that events or ievents options are well configured.

28

Invalid sort mode for RHTML builder. Accepted values are only "simple" or "complex".

How to resolve: Make sure that sortMode option is either "simple" or "complex".

29

Missing format in export element. A menu HTML element for the export menu does not contain a data-format attribute. Such attribute is used to obtain the export type.

How to resolve: Make sure that each item configured inside exportFormats contain a 'format' and 'type' property.

  exportFormats: [
    {
      name: "Fooes",
      format: "foo",
      type: "text/foo",
      cs: true
    },

30

Missing type in export element.

How to resolve: Make sure that each item configured inside exportFormats contain a 'type' property.

  exportFormats: [
    {
      name: "Fooes",
      format: "foo",
      type: "text/foo", // <---
      cs: true
    },

31

Invalid getItemTemplate function in extra view. An extra view was configured with a getItemTemplate function, but it's not returning a template to generate an HTML fragment for each item.

How to resolve: When defining a custom view with getItemTemplate function, make sure that this function returns a template HTML fragment.

    extraViews: [
      {
        name: "Squares",
        value: "squares",
        getItemTemplate: function () {
          // NB: names in curly braces are converted in the properties read from the items
          // (eventually formatted properties)
          return "<li title=\"{{name}}\" style=\"background-color:{{color}}\"></li>";
        }
      }
    ]

32

Missing property for template. A template returned by a custom view getItemTemplate function contains a name in curly braces that does not exist inside an item that should be rendered.

How to resolve: When defining a custom view with getItemTemplate function, make sure that this function returns a template HTML fragment compatible with table items.

33

Missing resolver in view configuration. A custom view is missing its resolver property.

How to resolve: When defining a custom view for the Rich HTML builder, make sure that it contains a resolver property (this object must implement a buildView function).

34

Invalid extra views configuration (null or falsy value).

How to resolve: Extra views must be configured as objects with name property.

35

Missing 'name' property in extra view configuration.

How to resolve: Extra views must be configured as objects with name property.

36

Cannot retrieve an item by event data.

How to resolve: Make sure that HTML elements generated for table items have 'kt-item' class.

37

Cannot retrieve an item by element data.

How to resolve: Make sure that HTML elements generated for table items have 'data-ix' attribute.

38

Cannot obtain HTML from parameter.

How to resolve: When defining an option for a custom view (for example, for a custom filters view), it should match the id of a script element contain an HTML fragment, or an HTML fragment itself, or a function returning an HTML fragment.

39

KingTable is not defined in global namespace. A function that requires the KingTable to be defined in global namespace was called when it wasn't.

How to resolve: Make sure that kingtable.js library is loaded before loading the script that is causing exception.

40

Tools is not an array or a function returning an array. A tools option was defined, but it's not an array or a function returning an array.

How to resolve: tools option must be an array or a function returning an array.

41

prepTools option is not a function.

How to resolve: prepTools option must be a function. It gets called in the context of the builder and with array of menu schema as parameter.

Clone this wiki locally