Giter VIP home page Giter VIP logo

treeviewandgridview's Introduction

TreeViewAndGridView (DEPRECATED) Support

This widget has been removed from the Marketplace and is deprecated. Do not use this widget.

The treeview and gridview widgets provide the highly customizable grid widgets as seen in home.mendix.com.

Contributing

For more information on contributing to this repository visit Contributing to a GitHub repository!

Description

The treeview and gridview widgets provide the highly customizable grid widgets as seen in home.mendix.com.

The Treeview widget is a feature rich widget to display tree like structures (or lists). Different kinds of associations and recursive structures can be rendered using this widget. The widget supports drag and drop out of the box.

The gridview can be used to display tabular data and supports filters, search, paging, editing and advanced renderings out of the box!

Dependencies

  • Mendix 3.0 environment

Gridview Configuration

The gridview configuration is quite similar to the treeview configuration. For details, please read the documentation of the properties in the modeler. Complex configurations are covered int he Treeview and Gridview demo project.

##Treeview Configuration This section only describes the general configuration of the widget. For detailed information about specific properties, please read the help texts of the widget properties inside the modeler. The best way to understand the configuration of the treeview widget is to read this documentation and inspect the treeview demo project.

Disclaimer: The correct behavior of the treeview depends highly in a correct configuration. Incoming support tickets which are a result of not carefully reading this documentation will not be taken into consideration. Furthermore a test project is always required, as the result of the many configuration scenarios available.

The treeview is capable of displaying several different associations in multiple directions in the same treeview. Configuring the widget should not be to hard if you follow the next 4 steps. For more complex scenario's see the sections below.The 4 steps correspond to the 4 Tree configuration properties of the widget.

1. Configure entities

As a prelude to your treeview setup, you need to mention all the entity types you are going to display in the widget here. If you use inheritance, it suffices to define only the most generic type.*

The treeview always require a context object (thus; the widget can only be used inside a dataview or templategrid). and can only display objects which are somehow related to your context. If you are in the rare case that you have no such context, see the demo project about how to create a dummy context. The context object should always be part of your entity configuration! Otherwise the treeview won't load at all.

For each type, you can define a view properties; sorting, cache bust (see the refreshing the tree section) and custom styling for this object type. We recommend to use classes and define them in your custom theme, as they provide a lot of flexibility and possibilities, but for a quick prototype inline styling might work as well. If you use drag and drop, the sort attribute should be an ascending float attribute. See the drag and drop section for more information.

When you configured all entities you intend to display in the widget, you can define the relations between them.

  • For inheritance, only the first matching configuration is always applied. So define the most generic type last.

2. Configure the associations to display

To define a relation, first select the object from where the association is leaving (association owner property). This allow you the select an association is the association property. The association property comes in two flavors, but you need to define only one, depending on the type of relation you want to display (as the tree supports both references and reference sets).

An important but complex property is the association direction. This property defines in which direction the relation should be used. Remember that the treeview always renders from parent to child. So if the owner is the child, than the association is actually used in the reverse direction. If you want to be able to navigate an association in two direction, you can just define the relation twice; one for each direction. See the first demo of the demo project for an example. The following table might clarify this as well:

Domain model Navigation direction
Order * --- referenceset ---> * Orderline From order to orderline: The association owner (that is; the order) is the parent. From orderline to order: The association owner (that is; the order) is the child (this is a bit artificial case)
Order 1 <---- reference ---- * Orderline From order to orderline: The association owner (that is; the orderline) is the child. From orderline to order: The association owner (that is; the orderline) is the parent

The show relation name property indicates if the items inside this relation should be wrapped inside a helper node. If so, the class and styling attributes are applied to this node.

For the constraint and drag and drop properties, see their respective sections. Note that using a constraint alters the refresh behavior of the widget, so use it carefully.

3. Configure the rendering

The best way to learn how to define the rendering is to just play around with it, or inspect the various example in the demo project. Just remember that after defining the entities and associations the treeview does not know how to display anything. So for every entity type you are using in the widget, you should define at least one rendering. For each rendering, do not forget to select the correct render mode.

To influence the layout of a rendering, the css properties width, clear and float are very useful. See the flower list in the demo project for an example. Be careful though, css properties in the style attribute should be separated by '|' (pipe) ore newlines. Semicolons as you would use in a CSS file are not supported.

The onclick action property indicates that a (part of) the rendering is clickable. The property refers to the name of an action as defined in step 4.

4. Define actions

Actions are pretty straight forward to define as well. If the applies to type property is left empty, the action can always be invoked and it will receive the context object as parameter. Otherwise, the microflow can only be invoked if the current selection matched the type of applies to.

Advanced: Refreshing

The content of an item is always refreshed automatically. The children of new items are not always refreshed automatically. The treeview tries to refresh automatically as much as possible, however, there are a few complex cases where this cant be done as the widget is not notified about new or deleted objects. Note that most of the cases explained below are demonstrated by the flower family example.

Case: add a new child when the reference owner is the child

Sadly, this cannot detected by the widget, as it does not trigger a change on the parent, and the child is not in the treeview yet. If you need this behavior, using a cache bust attribute (on the parent entity) is the way to go. Whenever the the treeview receives a new value for this attribute, it reloads the children of an item. The flower list example demonstrates this nicely.

Case: an object is deleted from the database entirely

The treeview always picks it up when an object is removed from a reference(set). However, if an object is deleted entirely, this will not result on a change of the the reference(set).

If the owner of the reference is not the object being deleted, just remove the referred object from the reference first and then delete that object (that can be done in the same microflow).

If the owner of the reference is the object being deleted, the parent needs to be refreshed manually, again this can be done by using the cache bust attribute of the parent.

Case: an object is added to a constrained relation

See the next section

Advanced: Constrained relations

When removing an item from a constrained relation, this is handled in the same way as removing an object from an unconstrained relation. However adding a child to a constrained relation is never picked up automatically, as the new object might not pass the given constraint. To avoid unnecessary retrieves from the server, you need to indicate in your model that an object needs to refetch its children by the cache bust attribute as explained above.

Advanced: Drag and drop

Enabling drag and drop on a relation allows items to be both dragged from it and dropped to it. The widget automatically calculates where an item can be dropped, based on the type of the object your are holding, the object or relation you are dragging over and the copy state.

The copy state is triggered by pressing the control key. If your domain model does not allow two parents of the same of a child (for example order 1 <-- reference * orderline does not allow to orders for an orderline) it is not allowed to drop.

If an item has a ascending float as sort attribute, it is possible to drop on a specific position in a relation. The average of the two nearest item is then used as the new position. Note that there is a small chance that an index collision occurs, if you want to avoid this, you have to check this in your microflow when the drop microflow is triggered.

The treeview does not persist any drop operations, nor does it refresh any data, it relies on the ondrop microflow to know what should be done next. This means that you can alter the actual drop in your microflow, or even roll it back.

The actual ondrop microflows that are triggered depend on your domain model. If the drag and drop operation results in only one reference being changed (this is usually the case if the owner is the child) than the ondrop microflow of that child is triggered. However, if the drop operation moves an item from one referenceset based relation to another, where the owner is the parent, the on drop microflows of both the old an new parent is triggered, as they are the objects that are actually being changed by the drop. See the flower family and organizations examples which display the various variations.

Known bugs

  • IE 7 will not render the layout of the widget correctly due to its complexity. The functional behavior should be correct however, so you might consider applying project specific custom styling for IE 7 on this widget. We however do not support this scenario.

treeviewandgridview's People

Contributors

andries-smit avatar brtn avatar ebrpol avatar jeltemx avatar kevinvlaanderen avatar roelandsalij avatar rvthof avatar simonmartyr avatar tibormx avatar vietduc1441 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

treeviewandgridview's Issues

Prefetch

Hi, does the prefetch function actually work or is the configuration option a dead option? I do not see any difference with large datasets.

circular dependencies in renderEdge and renderNode

It seems that there is a circular dependencies in RenderEdge and RenderNode
In RenderEdge:

define([
    "dojo/_base/declare",
    "TreeView/widget/TreeView/RenderNode"
], function (declare, RenderNode) {
    "use strict";

In RenderNode

define([
    "dojo/_base/declare",
    "TreeView/widget/TreeView/RenderEdge"
], function (declare, RenderEdge) {
    "use strict";

    return declare("TreeView.widget.TreeView.RenderNode", null, {

So from RenderEdge, line 106 will cause error:
new RenderNode(this.tree.dict[childguid], this.parent, this.type);
RenderNode is not a contructor

Fixes needed to run in Mendix 7

Hallo,
in order to use the widget in mendix 7 I had to change few lines of code in TreeView.js:

  • line 1104 and 1212 I had to replace 'Float' with 'Decimal';
  • line 274 I had to replace
    type.isRefset = type.parentassocsingle == ""
    with
    type.isRefset = type.parentassocsingle == "" || !type.parentassocsingle,
    because otherwise when you select a reference selector association, you wrongly get isRefSet == false.

Regards

Undefined function in Mx7

Error: TreeView_widget_TreeView_1.applyContext: Error: TreeView_widget_TreeView_1.applyContext: TypeError: mx.data.objectUpdateNotification is not a function
Line 410 TreeView.js

Displaying Association

Hi,

I am trying to use the grid view widget in displaying an attribute that is two associations from the main object.
Example: The entity type is 'ProjectMember' and the rendered attribute value is 'ProjectMember -> Employee -> Organization/Name'. The widget mentions that there are items available, however no records are displayed.

I have noticed that the widget causes an error if the "Use Database" option is set to Yes, I have to set it to No for the widget to work.

I am using version 6.10.3

Best regards and thanks,
Rami Bou Hadir

Async issues conditional visibility

Commons.js has a mx.data.get that will get the object over a reference. This action is async. This means that tmp will be null the first time. The second time you call this, the object is cached and tmp will not be null

getObjectAttr needs to be an async function, using a callback or deferred. The problem is that this is used in a lot of other functions

Not working in Mendix 7.2.0

Displaying a hierarchy with the treeview widget in a Mendix v7.2.0 project throws an error in the browser's console "Error: Cannot read property 'set' of undefined". Widget's version used is 4.4.

Please find attached sample mda-project.

TreeView-v7.2.zip

Null value of data in update function

/* context applied */
    update : function(data, cb) {
        var guid = data.getGUID();

in file TreeView.js
Sometime, data is null, causing the "loading popup" persists forever.

onclick functionality not working

Hi Team,

I'm using this widget in Mx 7.4.0 version and onclick functionality is not working after upgarding from 6.7.1.

Expectation: Onclick of a row in treewidget associated grid to be shown.

Regards,
Swathi

Show enum values as picture in TreeView

Mendix enumeration values can have an image attached to it.
It would be nice to have the option to show this image in the tree instead of the enum value.

Selection Actions

I was trying to use the tree view to populate a table on the same page with details about the object selected. The only way know of doing this is to create a non peristable object that represents the model and have a member of that object be the selected object of the tree view (or grid view). The microflow requires the 2 inputs. One being the model and the other being the object that was selected by the control. I was not able to do this in your tree view because it does not detect parent contexts or seem to have the ability to add a second input parameter to actions that are called from the selection of a node. Would it be possible to change this so it works like the other controls in mendix?

Button images not showing

I am using the treeview widget in one of my 5.21.3 projects. Basically it works fine, but I have just one issue. When I create a button (in the widget settings 4-Actions) in the header of the treeview and add a image to it (in tab 2-Button), it is not showing in the frontend of the application. The button is rendered and the caption is showing but simply not the image.

For reference I also tried the treeview demo project in 5.21.3 and there the button image is also not showing. Same goes for version 5.15.1

Urgent issue: Version 4.2 do not build on Acceptance and Production environments

Hi,
I like your widgets and use them throughout my projects. It appears there was recently a critical issue fixed regarding the memory leak, and downloaded the latest version 4.2.

The new version 4.2 of the Gridview widget does not build in acceptance and production environments using Mendix 6.2.1. It builds and runs fine in the local environment using the same Mendix Modeler version.

Could you perhaps look at this urgently.

The only log trace I could get:
v6.2.1
ERROR: Could not build your widgets. This may be due to outdated widgets in your project.
You can check which widgets failed to build by clicking Tools > Check Widgets.
BUILD FAILED

logger usage in widget JS code

When using the widget the client issues this warning:

DEPRECATED: logger, use mx.logger instead -- will be removed in version: 11.0

I suggest widhet + demo is rebuild voor 9.0 and this issue is solved in all JS code

A number of deprecated function when converting to mx7

DEPRECATED: _Scriptable mixin will be removed in version 8.0. The mixin does not have any effect anymore. The only supported interface was 'close' and to continue offering it now, widget should just implement a method 'close(callback)'.
DEPRECATED: mendix.lang.nullExec. Use plain javascript if instead -- will be removed in version: 9.0 RenderNode.js RenderEdge.js
DEPRECATED: mx.data.save will be removed in version 8.0. The 'mx.data.save' function does not have any effect anymore. MxObjects are now automatically saved as part of 'mx.data.commit', 'mx.data.rollback', 'mx.data.action' and 'mx.data.saveDocument' treeView.js

mx.data.save deprecated since Mx 6.8

TreeView and GridView use mx.data.save in various places. This is deprecated since Mendix 6.8 and appears to be causing a failure to refresh the UI after adding a a new item, when the widget is used in a 6.8 project.

Could not create widget TreeView.widget.TreeView

Could not create treeview widget in mendix 7.10.

mxui.js?636501404037003141:7 Could not create widget TreeView.widget.TreeView TypeError: mxui.wm.focus.addBox is not a function
at Object._setupLayout (TreeView.js?636501404037003141:247)
at Object.postCreate (TreeView.js?636501404037003141:152)
at Object.create (mxui.js?636501404037003141:7)
at Object.postscript (mxui.js?636501404037003141:7)
at new (mxui.js?636501404037003141:7)
at mxui.js?636501404037003141:7
at Object.forEach (mxui.js?636501404037003141:7)
at i (mxui.js?636501404037003141:7)
at Object.parseTopLevel (mxui.js?636501404037003141:7)
at Object.parseContent (mxui.js?636501404037003141:7)

Demo project is out of date

The demo project requires v6 and without it, it's quite hard to get this setup. Either update or remove the project IMHO.

inline edit-ability based on access permissions

Currently there is: "Editable column Yes/No (Whether the value can be edited. Note that this is only supported for certain value types. (Currently: enumerations, booleans, references and referencesets))"

It would be nice when this is not necessary and the edit-ability is based on the access permissions of the attribute of the displayed entity.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.