1. Binding Lists
I wonder how I could bind a ObservableCollection to a Radiogroup:
new Section(){
new RootElement("Mandanten", new RadioGroup("mandanten", 2)) {
new Section(){
new RadioElement("Kupus", "mandanten"),
new RadioElement("Kajmak", "mandanten")
}
}
}
as you see here I'm creating 2 Items/Elements manually but I miss something like an "ItemsSource".
If its not possible, what recommendation would you give me? To use witch Control (to bind Lists)?
2. CommandBinding
As I see theres no "button" in MonoTouch.Dialog. So I saw that we'll use "StringElement".
I tried it, but after tapping on the "button" nothing happened:
new StringElement("Login").Bind(this, "SelectedCommand LoginCommand")
I'm not sure whats wrong, maybe I need to use here the new "variant", like that:
new EntryElement ("User", "Loginuser", ViewModel.User).Bind(target, v => v.Value, t => t.User),
But I'm not sure how to build that similiar code to bind a command for a particular "stringelement" (in that case - a button with the ontap event)..
Any help appreciated!
1. Binding lists
An example of binding dynamic ObservableCollection lists is in https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/ThirdView.cs - it uses some custom elements from https://github.com/slodge/MvvmCross-Tutorials/tree/master/DialogExamples/DialogExamples.Touch/BindableElements - which was based on the sample from https://github.com/asednev/MvvmCross.AlexeysExtensions
Because of the way Radio lists are internally implemented, I don't know if the same ObservableCollection binding approach would work for radio lists - someone would need to prototype and experiment to work this out. However, a simple fixed radio list is shown in https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/FirstView.cs
2. CommandBinding
See an example in: https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/FirstView.cs
new Section("Action")
{
new StringElement("Second").Bind(bindings, element => element.SelectedCommand, vm => vm.GoSecondCommand),
new StringElement("Bindable Elements").Bind(bindings, element => element.SelectedCommand, vm => vm.BindableElementsCommand)
},
Related
I'm trying to implement integration tests on our React frontend which uses Ant design. Whenever we create a table, we add an action column in which we have a Menu and Menu Items to perform certain actions.
However, I seem unable to find the correct button in the menu item when using react-testing-library. The menu Ant design uses is rc-menu and I believe it renders outside of the rendered component.
Reading the testing-library documentation, I've tried using baseElement and queryByRole to get the correct DOM element, but it doesn't find anything.
Here's an example of what I'm trying to do. It's all async since the table has to wait on certain data before it gets filled in, just an FYI.
Tried it on codesandbox
const row = await screen.findByRole('row', {
name: /test/i
})
const menu = await within(row).findByRole('menu')
fireEvent.mouseDown(menu)
expect(queryByRole('button', { name: /delete/i })).toBeDisabled()
the menu being opened with the delete action as menu item
I had a same issue testing antd + rc-menu component. Looks like the issue is related to delayed popup rendering. Here is an example how I solved it:
jest.useFakeTimers();
const { queryByTestId, getByText } = renderMyComponent();
const nav = await waitFor(() => getByText("My Menu item text"));
act(() => {
fireEvent.mouseEnter(nav);
jest.runAllTimers(); // ! <- this was a trick !
});
jest.useRealTimers();
expect(queryByTestId("submenu-item-test-id")).toBeTruthy();
I would like to know how to update a row/col and or layout from an external js file on webix. Let's say I have a menu at the left of the screen (col[]) and want to update the right column based on a menu selection. If the menu is composed by
Customers
Orders
Products
And want to update the right column based on the selection calling customers.js, orders.js and products.js
Just like http://webix.com/demos/admin-app/#!/app/orders
That example is very advanced for me, I would like to learn some basic method.
Thanks
Oscar P
You can use webix.ui command or addView API to add a new UI to some specific place on the page.
webix.ajax("config.json", function(text){
$$("layout").addView( JSON.parse(text) );
})
or
webix.ajax("config.json", function(text){
webix.ui( JSON.parse(text), $$("cell_to_replace"));
})
Aquatic,
I also found out an example with .showBatch() API but the console shows "Uncaught TypeError: $$(...).addView is not a function" on both functions, are those part of PRO version? what is wrong?
My code is:
$$("workArea").addView("clientes");
or
$$("workArea").showBatch("batClientes");
on:{
onMenuItemClick:function(id) {
$$("workArea").addView(id);
}
}
Can I use setFilteringMode of ComboBox in ListSelect ? I didn't found anyway to do this. I am so supprised due to this mothod didn't support in ListSelect. I don't think ComboBox and ListSelect are too many differences. So , if I want to use Filtering in ListSelect , how can I figure it out ?
As a possible solution, you can create a textfield below your ListSelect and use a filterable container (https://vaadin.com/api/com/vaadin/data/Container.Filterable.html) as the data source of your ListSelect and apply a container filter e.g. on each "return" in this textfield or even on each text-change event.
IndexedContainer c = new IndexedContainer();
listSelect.setContainerDataSource(c);
Filter filter = new SimpleStringFilter("name", "Douglas", true, false);
c.addContainerFilter(filter);
See the Book of Vaadin - Filterable Containers
I am using the pure Razor style definition for a Kendo Menu:
#using Kendo.Mvc.UI
#(Html.Kendo().Menu()
.Name("main-menu")
.Items(items1 =>
{
items1.Add().Text("Home").Url(#Url.Action("Index", "Home"));
items1.Add().Text("Movements").Items(subs =>
{
subs.Add().Text("Import Data").Action("Import", "VehicleMovementBatch");
subs.Add().Text("View Movements");
});
items1.Add().Text("Presences");
items1.Add().Text("Billing");
items1.Add().Text("Config").Items(items2 =>
{
items2.Add().Text("Pricing").Action("Index", "PriceRule");
items2.Add().Text("Users");
});
items1.Add().Text("Control");
})
)
I can find absolutely bloody nothing anywhere on all the internets, that even hints how to do do this properly. The closest I have is defining the DataSource in JavaScript object notation, with separators, and assigning it to the grid oj the client side at run time. This is definitely a good example of a case where can only pray to all the gods that the API isn't as superlatively inadequate as the documentation.
This is all you need to do. Figured it out on my own because I couldn't find an answer anywhere on the web.
items1.Add().Text("<hr/>").Encoded(false).Enabled(false);
The < hr / > thing didn't work for me in kendo 2014.1.528
This does:
children.Add().Text("<div class='k-separator'></div>").Encoded(false).Enabled(false);
So an example would be:
items.Add().Text("Menu X").ImageUrl(Url.Content("~/Content/img/menux_16E.png"))
.Items(children =>
{
children.Add().Text("Item 1").ImageUrl(Url.Content("~/Content/img/item1_16E.png"));
children.Add().Text("<div class='k-separator'></div>").Encoded(false).Enabled(false);
children.Add().Text("Item 3").ImageUrl(Url.Content("~/Content/img/item3_16E.png"));
});
To help anyone coming across this issue in the future, you can add a separator directly with the following:
items.Add().Separator(true);
This works since at least v2013.2.918, since that is what I am using.
Justin
I have v2016.3.914 and items.Add().Separator(true); creates an unwanted horizontal scrollbar on an RTL page.
I solved it using this:
inner.Add().Separator(true).HtmlAttributes(new { style = "width: 99%;" });
I have a KendoUI Grid I'm using an MVC web application, all working fine however I want to add a custom command button that is shown conditionally in the UI and simply executes a command on my controller passing it the required parameter.
columns.Command(command => command.Custom("UnlockAccount").SendDataKeys(true).Click())
The command is specified as above but I only want the button to show when the DataItems IsLocked property is true.
I also cannot figure out how to just call and method on the controller rather. I cannot find a demo of this on the Kendo site and not sure how to move this forward.
Here is a specific example for using client templates for conditional command buttons.
const string ShowUpdateButton = "#if (IsNetReversal == false) {#<a class='k-button k-button-icontext k-grid-edit' href='\\#'><span class='k-icon k-edit'></span>Update</a>#}#";
const string ShowReverseButton = "#if (IsNetReversal == false) {#<a class='k-button k-button-icontext k-grid-reverse' href='/JournalDetail/Reverse/#: ID #' ><span class='k-icon k-reverse'></span>Reverse</a>#}#";
const string ShowDeleteButton = "#if (IsAdjustment == true) {#<a class='k-button k-button-icontext k-grid-delete' href='\\#'><span class='k-icon k-delete'></span>Delete</a>#}#";
You can do the template inline but I find it easier (particularly for multiple buttons) if you declare constants and then use string.format to concatenate them.
col.Template(o => o).ClientTemplate(string.Format("{0}{1}{2}", ShowUpdateButton, ShowDeleteButton, ShowReverseButton));
The upside is it will work with popup editor whereas jquery hacks will ignore the conditional status when a user cancels out of edit. A cancel from the popup editor will restore the grid row from the viewmodel or wherever Kendo stores it which results in button states from before any jquery/javascript hack. The method above will also auto-wire the standard commands since I copied their HTML output for the client template.
The downside is that if Kendo changes their pattern for command buttons the client template may fail. I tired several other methods besides this one and the downside to this method seems better than the other methods.
Note on Kendo Forums: As of the date of this post, they do not appear to allow people who do not pay for support to post to the forums so I would suggest posting questions here instead. They monitor Stack Overflow and in my experience they seem to answer questions more quickly here.
Use template column instead - via the ClientTemplate method.
Conditional templates are covered here and multiple times on the forums - the Command columns is not that flexible.
As of the December 2018 release of Kendo, you can now conditionally display custom buttons more easily, but it still relies on JavaScript to do its work, this function should be defined before your dataGrid or you'll run into issues.
function showCommand(dataItem) {
console.log("determining to hide or show" + dataItem);
// show the Edit button for the item with Status='New'
if (dataItem.Status == 'New') {
return true;
}
else {
return false;
}
}
Then the code for the Grid.
.Columns (columns => {
columns.Command (
command => command.Custom ("Approve")
.Visible ("showCommand")
.Click ("approveFunc")
)
.Width (100)
.HeaderTemplate ("Actions")
})
You can control custom command button visibility by Visible property.
columns.Command(command => command.Custom("UnlockAccount").SendDataKeys(true).Click().Visible("unlockAccountVisible"))
Visible property accepts JS function name and passes current dataItem as an argument.
JS function that evaluates button visibility:
<script>
function unlockAccountVisible(dataItem) {
// show the UnlockAccount button only when data item property IsLocked == true
return dataItem.IsLocked;
}
</script>
Read more in Show Command Buttons Conditionally kendo-ui documentation article.