I'm creating a tableview that has 4 main headers, and each header has a "costs" and "units" property.
In plain JavaFx, you can add columns to columns and make this split:
TableColumn emailCol = new TableColumn("Email");
TableColumn firstEmailCol = new TableColumn("Primary");
TableColumn secondEmailCol = new TableColumn("Secondary");
emailCol.getColumns().addAll(firstEmailCol, secondEmailCol);
is it possible to do this in tornadoFX?
You create nested columns in TornadoFX using the nestedColumn builder:
nestedColumn("header1") {
column("costs", Item::costsProperty)
column("units", Item::unitsProperty)
}
In addition to creating the columns, this code also creates a valueFactory for each column :)
Another very important thing to note, is that you can do absolutely everything you can do in JavaFX within TornadoFX. TornadoFX never hides the underlying JavaFX APIs, so even if we didn't have a nestedColumn builder, you could have used your exact code above, just with Kotlin syntax, and it would just work.
If you ever hit a case where you don't know how to do something in TornadoFX, you can always use the traditional JavaFX approach to achieve the same :)
Related
I'm trying to add objects (simple key-value pairs) to a list.
However, the v-model is still bound to the previously added objects, so if I add "ObjectOne" vith "ValueOne", then try to add "ObjectTwo" with "ValueTwo", "ObjectOne" gets edited AND "ObjectTwo" gets added.
I am by no mean an expert in Javascript, so it might not be related to VueJS.
I can obviously make this work with a method per list .
The point is that my model has multiple lists of key value pair to be edited, so I tried making a generic method :
addToList: function(value, list){
console.log("Adding " + value + " to list "+list);
list.push(value);
value={};
},
This method works if used on "simple" lists (like an array of string), but not on "objects" list.
My guess is that as I try to clean "value" instead of "this.value", the reference still points to the same object, but since I don't know what "value" will be when called, I don't know how to do this.
Here is the fiddle with a re-creation of my issue.
My objective would be to be able to use the "addToList" function to add to any list, without having to re-write a function for each list.
Thank you for your help.
The above behaviour is because you are updating the value of same object whenever you add a new todo task.You need to set your object again to add new values as below.
addToList(value, todos){
this.todos.push(value);
this.anotherTodo={ text:'',
done:'false'}
}
Working fiddle here.
I post this as an answer, but if someone has a better way to do it, I'm all hear.
I solved the way by adding a watch on my list. When the list changes, I clean the model object that's added to it.
In my production work, I had to add a computed property, since I can't add a watch on an object's property, then a watch on said computed property :
watch:{
todos(){
this.anotherTodo={};
},
fiddle as demo
I want to execute the method remove_column on an instance of cl_salv_column_table but because of its visibility level, I am not able to do so.
Plan:
I already tried inheriting from cl_salv_columns_list and then perform the call inside the remove-method:
CLASS lcl_columns_list DEFINITION INHERITING FROM CL_SALV_COLUMNS_LIST.
PUBLIC SECTION.
METHODS:
remove IMPORTING iw_colname TYPE string.
ENDCLASS.
But apparently my casting knowledge got rusty as I'm not able to figure out an appropriate solution.
This is my current hierarchy - the red arrows show the way I would have to take:
My approach looks like this:
DATA lo_column_list TYPE REF TO lcl_columns_list.
lo_column_list ?= CAST cl_salv_columns_list( lo_columns ).
But it fails with:
CX_SY_MOVE_CAST_ERROR
Source type: \CLASS=CL_SALV_COLUMNS_TABLE
Target type: "\PROGRAM=XXX\CLASS=LCL_COLUMNS_LIST"
Background:
My task is to select all columns of 3 tables (which would be done like SELECT t1~*, t2~*, t3~* ...) as long as their names don't conflict (e.g. field MANDT should only be displayed once). This would require defining a very big structure and kick the size of the selection list to a maximum.
To avoid this, I wanted to make use of the type generated by my inline-declaration. Hiding the individual columns via set_visible( abap_false ) would still display them in the layout manager - which looks really ugly.
Is there any other way to accomplish my target?
Use set_technical( abap_true ) to hide the columns entirely. As for your approach - sorry, inheritance does not work that way - in no statically typed object oriented language that I know. You can't 'recast' an instantiated object to a different class. You would need to modify the framework extensively to support that.
The vast majority of the documentation for this plugin indicates that you initialize it with
$('#example').dataTable();
However http://www.datatables.net/examples/api/multi_filter_select.html initializes using
$('#example').DataTable();
The resultant objects differ quite a lot, and the example URL above doesn't work when I initialize with a lower-case 'D', however pretty much everything else requires the lower-case 'D' initialization.
Can someone please explain to me why there's a difference, and how to make the two play nice together? Essentially I need the multi-filter-select functionality, but also need to tack on some other calls / plugins, which don't seem to like the upper-case 'D' initialization.
Basically, the two constructurs return different objects.
dataTable constructor
var table = $(<selector>).dataTable()
dataTable is the oldschool dataTables constructur, which returns a jQuery object. This jQuery object is enriched with a set of API methods in hungarian notation format, such as fnFilter, fnDeleteRow and so on. See a complete list of API methods here. Examples :
table.fnDeleteRow(0);
table.fnAddData(['E', 'F']);
dataTable is supported by all 1.9.x / 1.10.x versions.
DataTable constructor
var table = $(<selector>).DataTable()
The DataTable constructor was introduced in 1.10.x, and returns a huge API object with full read/write access to pages, rows, cells and more, see manual. Example equivalences :
table.row(0).remove();
table.row.add(['E', 'F']).draw();
Combining dataTable and DataTable
If you maintain old code, or for some reason need to use the oldschool dataTable constructor, but still needs to use the new API, the jQuery object is extended (from 1.10.0) with a .api() method that returns the new API. Example equivalences :
var table = $('#example').dataTable();
table.api().row(0).remove();
table.api().row.add(['E', 'F']).draw();
The old API like table.fnDeleteRow(0) still works. So to your concern :
Essentially I need the multi-filter-select functionality, but also
need to tack on some other calls / plugins, which don't seem to like
the upper-case 'D' initialization.
As you see, you can do both! Initialize dataTables the old way, and use .api() when you need access to the new API.
Why is so many official examples using dataTable()?
Well, you do not need to use the DataTable constructor. If you dont use the new API, there is no reason for using the DataTable constructur. The oldschool dataTable constructor is not deprecated. DataTables is mostly one mans work. It is a huge task to maintain and develop and obviously very time consuming to maintain a huge website with forum, manuals, tons of examples and so on. This is only a guess, but I assume Allan Jardine by now only have changed dataTable to DataTable where it is actually needed, simply bacause he cant do it all in one step.
I used the CRUD generator from a legacy database. When searching for a column value I get the following error:
htmlspecialchars() expects parameter 1 to be string, array given (/usr/local/share/yii/framework/web/helpers/CHtml.php:103)
The problem is that the model has an existing column named "attributes" which is creating a conflict. I removed the entry from the _search.php and commented out all instances in the model hoping to at least get it working but no luck. Any suggestions would be appreciated.
Thanks.
Every CActiveRecord instance (or CModel instance for that matter) has a getter/setter named attributes with which all the attributes can be set. This leads to a conflict because the generated crud code uses the attributes attribute expecting it works as described before.
The controller does something like:
$model->attributes=$_POST['ModelClassName'];
// or
$model->attributes=$_GET['ModelClassName'];
This is meant to set al the (safe) attributes of the model at once. Instead this overwrites the database attribute attributes of your legacy DB model.
This in turn leads to the error you describe, because $_GET['ModelClassName'] and $_POST['ModelClassName'] typically contain arrays of data.
I guess the easiest fix would be to directly call the setter function for the "normal" attributes behavior which would lead to replacing the lines mentioned above with something like the following:
// in the controller
$model->setAttributes($_POST['ModelClassName']);
// and
$model->setAttributes($_GET['ModelClassName']);
I think rest of the generated CRUD code (the views) could and should be left untouched to make it work.
If you want to know how and why this works, it's best to do some research into the __get and __set magic functions and how they're used in the yii framework.
Is there any way to create an “alias” for a component?
I have a “Criteria Builder” that takes strings in the format of “Address.City” (or “User.Address.City”, …) and creates an ICriteria (filters and sorts) based on it.
I am using components to map the “Address” class so it stays in the same table as “User”.
The exception I am getting is:
NHibernate.QueryExceptioncould not resolve property: City of: MyNamespace.User
If I attempt to do not create an “alias” for the Address Component, it works just fine.
However, as it is a criteria builder, is there a way to detect that “Address” is a component and avoid the call criteria.CreateAlias(“Address”)? Any work around?
This is the same question as mine, however the solution is not viable to me (I do not create criteria manually for each query).
Any help would be much appreciated!
You can't create an Alias for Address because Address is not a mapped entity. The only difference between CreateAlias and CreateCriteria is that the former returns the original Criteria, whereas the latter returns the new Subcriteria. So the only classes you can create Criteria for are classes that have been mapped. Since components are not mapped classes, you can't create a criteria around them.
The only suggestion I have is to have your Address class either to implement an empty descriptor interface like IComponent or mark it with a custom ComponentAttribute. Then your CriteriaBuilder can check whether or not the class it's creating a criteria for has this meta data and ignore it.