I have a combo box on a view that will have a default of "Active" when the form is loaded. Whose job is it to set the combobox to "Active", the code behind in the loaded method or the View Model?
Bill
I'd say it's the ViewModel's job. There are at least 2 approaches to do it:
bind the SelectedItem of the combo to a property of the ViewModel, and set this property to the value you want
obtain the default view for the collection (CollectionViewSource.GetDefaultView) and set the current item with the MoveCurrentTo method (don't forget to set IsSynchronizedWithCurrentItem to true on the ComboBox)
Related
I understood how to create a ListStore model, a GtkTreeView and how to link them together with Glade.
Now I'd like to set the property "xalign" of one GtkCellRender. It seems I can link the attribute "xalign" to the model (I can set the relevant column in the model that stores the value of "xalign" property for that row).
However I'd like to set "xalign" property to 0.5 value for all the rows.
I was able to have this effect through code:
self.cellName.set_property("xalign", 0.5)
I'm finding a way to set the property directly in Glade, so I can avoid to write code for that.
Right click on the TreeView > Edit > Hiearchy > Select Cell Renderer > Common Properties and Attributes > Horizontal Alightment.
I'm using Extjs5.1 powered by a MVC oriented code style.
I've got a main view which inherits from Ext.panel.Panel with a border layout.
On the east region, there's a grid with a store containing several records (or "models", I don't really know what terminology I should use here). (the "master grid")
On the center region, there is another view that inherits from a Ext.form.Panel and which is supposed to display the selected item of the grid . (the "slave form")
My goal is to refresh the "slave form" with the selected record of the "master grid".
The only way I found to "communicate" between the grid and the form is to execute a fireEvent('selectRecord', ...) from the main view controller and to listen to him inside the form view controller, but it seems odd as the form view is a child item of the main view.
Is there a more common way to do that?
By corrolary, is it a fine practice to make a view call functions of another view directly or should I make only their respective controllers interact?
What I usually do and I believe is the most common approach for this, is having a selectionchange event listener, that updates your form like this:
listeners : {
selectionchange: function(model, records) {
var rec = records[0];
if (rec) {
formpanel.getForm().loadRecord(rec);
}
}
}
for this to work, the name property of your form fields must match the name of the fields in the grid store model.
There is an example of this here: http://dev.sencha.com/extjs/5.1.0/examples/kitchensink/#form-grid
I have a viewmodel which I am binding to a drop-down. I want to clear the value form the viewmodel if that value is not present in the drop-down options.
Any help on this? Thanks in advance.
I think a better way to go about this is to actually use a ComboBox. http://docs.kendoui.com/api/web/combobox
Which allows an unselected state.
$("#products").kendoComboBox({
dataTextField: "text",
dataValueField: "value",
dataSource: data
})
.closest(".k-widget")
.attr("id", "products_wrapper");
And then clearing the value from the combo box when its not present in the data set.
var combobox = $("#products").data("kendoComboBox");
combobox.text("");
Have a look here: http://jsfiddle.net/amomsen/UKfz6/3/
I want to make a checkbox in the form editor of Base to fill boolean values (in this case, "Male", and "Female") in my table.
I am currently stuck in the checkbox control window's "Data" tab because I do not know what to put in the fields "Reference value (on)" and "Reference value (off)".
I know that in the table design view that Base refers to the boolean TRUE/FALSE values as "Yes" and "No". Should I use Yes and No as reference values? Should I go TRUE and FALSE? Or 1 and 0? I can just assign arbitrary designations for male and female if I know what to put in the reference value.
Ok, I tested it by trial and error. One apparently has to use TRUE and FALSE as the reference values, otherwise, Base will not fill the boolean checkbox in the table even if you've filled it in the form.
i have two dropdowns using same model and sets the value into it. Dropdown1 will visible on screen always and Dropdown2, will be visible for only one particular option choosen in Dropdown1. and i am making an query to the DB based on the selections in dropdowns.
But when i have both the dropdown first and then hide the second one, The value already set but the Dropdown2 is still avalible in my model, and making my query to fetch improper data.
So can any one suggest me an idea, how to set the value to null for the attribute which is actually set but dropdown2, if dropdown2 is inVisible.
(i tried to set the ModelObject to null, when making the dropdown2 invisible (using AjaxFormComponentupdateBehavior), but when i make the dropdown2, visible again, it returns null,even if i make any selection in it)
Are you using a LoadableDetachableModel ? try to explicitly detach model from that dropdown on setHide event. I did not try it though.