is it possible to add 3 anchors/ links in one cell of GWT celltable
like this
add/delete/copy
these are 3 anchors in one cell with different click handlers for all three of them ..
Thanks
What you are looking for is the CompositeCell.
The idea will be for you to create 3 separate Column (or lightweight HasCell impementations using ActionCell.Delegate for example) objects for your actions and instead of adding them to the table one by one you would add them as part of the CompositeCell.
It may seem a little counterintuitive to add HasCell implementations into an actual cell, but here is an example, from another Stackoverflow question: Does anyone have a working examples of ActionCells working within a CompositeCell?
You can't use Anchors because you can't use any widgets. However, you can render three different <a> elements and then override onBrowserEvent to catch clicks on them.
It may be simpler to use three separate columns and use a ClickableTextCell or something similar for each one.
Related
Here is a simplified example of my problem:
I want to make the edit box 1 or 2 visible, depending on whether a checkbox of box 1 or box 2 is checked. The variables "variableCheckbox1" and "variableCheckbox2" are connected to the respective ceckboxes.
I have written a function as shown in the picture. The function is called from the EditBox 1 ("Enabled"). This is a possible solution for ONE box each.
Does anyone have an idea if there is a more elegant way to do this for a very high number of checkboxes / edit boxes?
A possible solution would be to write a function with a switch case for each variable in my model, called from each box. A very inelegant solution would be to make a single function for each box, but I don't consider that a good way.
If you want this for a large number, turn the entire setup into its own agent type: Checkbox and editbox. Instantiate as needed, you can add a parameter to specify what this is about exactly...
This would be the most generic and powerful approach...
if this works for you, you can use replications for checkboxes and editboxes and associate them together through the index... and then just add the code in the visible field of the edit box... Of course you will have to determine their positions programatically
I want to know if it's possible to make first two lines (Titles and horizontal line in the image below) always show on top and to be unclickable, to make them something like a header of the current listbox.
I think that your approach is not feasible since this is just not how listboxes work (i.e. it's not a spreadsheet where you fix the top rows). Having said that, you might be able to create something that looks like what you're suggesting, by creating two listboxes one below the other, making the top one read-only or non-interactable (or better yet, make the top one a static text label or a text area).
Another thing I'd like to comment about is the structure of your listbox. In terms of UX, it's uncommon for a user to choose two things at the same time. So even if this makes sense in your context, I would advise to split it into two lists, and have them change each other within callbacks.
My problem is that I implement multiple times the same row.zul. Now I have an ID error because the row.zul file uses static id's.
In zk 8.0 it is possible to use the tag but I can't use that because we are here at a very old version (3.6.4). Do you know any possibilities to solve that problem? I need to give the elements ID's because I want to read from them
You don't need to autogenerate id's.
They need to be in the correct idScope.
An idscope is marked by the interface IdSpace.
So you need to put the row in a separate idScope, so just wrap a component who implement the IdSpace like window, include or create your own component like extends Div implements IdScope.
If you use CSS selectors, remember that you need to alter it a little bit.
What would be the best approach to implement a form with a variable number of text fields? I'm thinking something like this:
textField1 (removeButton)
textField2 (removeButton)
textField3 (removeButton)
addNewTextFieldButton
I would like this to bind to a list of strings.
I achieved this with an editable grid with a single column and buttons to add/delete rows.
This component is very well integrated with GWT Editor framework so you can bind your grid to a list of objects using a ListStoreEditor
The best approach would be to use the GWT Editor framework. GXT's fields are very well integrated with the Editor framework.
Here is a very rough example of how you might approach this problem.
You would start by creating one Editor for the thing you are wanting to bind to. In your case, I think a composite which contains a TextField (which is bound to the string) and a button. The button won't actually bind to anything, but you will provide a way for something which uses this class to register a SelectHandler against it. Let's call this editor SubEditor.
Once you create a UI component which is designed to bind to one string, you will next create a ListEditor<String, SubEditor> which will bind to a List<String> which will compose a view, consisting of one SubEditor per each String in the bound list.
You don't really need to create the SubEditor, as you could construct something as simple as what you want within your ListEditor's EditorSource class (read through the tutorials on ListEditors).
Again, I want to emphasize the this is a ROUGH example on how to get started. I hope there is enough information here for you to fill in the pieces.
The following SO question has helped me out a lot:
Using GWT Editors with a complex usecase
I have a list of widgets which needs to be sorted. I want to create a container for these list of widgets to re-sort them each time new widget is added. How can I do it?
I can see the following ways:
a straightforward way is place them into arraylist and sort via Comparator, but after a new element is added we have to remove all list from container and add them again, in a new order.
use some sorting container. i have found only CellTable for this. But actually I dont need its rich functionality - I have only one column, dont need to sort on user events, only when new element added or removed, - so is there something else I can utilize in my use case?
GWT 2.4
PS
Actually, I am looking for something, that can be expressed like "widget container backed by widget collection", i.e. I change collection - container changes its contents, how can I implement this, or where can I find it?
PPS
The widgets can be different, thats why I dont think I can use CellTable easily.
There is no straightforward way of re-sorting the elements in the DOM after you add a new widget.
When the widgets are attached you cannot just move them (change their position in the document structure) without detaching and re-attaching.
Well, with absolute positioning you can just change the left-top coordinates to move the items, if it is what you need.
I had a similar problem to solve when I had to sort TreeItem elements (no built-in sort method available). As a workaround, I read all the children into the list and remove them from the parent widget at the same time, then sort these items using Comparator and add them back to parent from the sorted list. Everything is in a single sort() method, which encapsulates all required functionality and kind of simplifies understanding of this code.
"widget container backed by widget collection"
I would like to learn about one like that that also can do sorting and re-attaching on the fly. But it still will be backed by the same detaching-attaching I assume. I would recommend you to write one yourself, that will fit your particular needs. Either you need a Tree or a FlowPanel or anything else - you can extend that and add sort() logic according to context. And override add() method accordingly. So, your first option looks like a possible solution to me.