I am trying to figure out how to add placeholder string value on every property inside a property grid that was not changed from the user.
So let's say you are trying to edit some object when you get prompted to do so you will get the following form.
If you changed the color property for example the result would be the following.
I tried to see if there is an attribute but it seems that there is not. DefaultValue is not suitable because the message is a string and the underlying property could be anything.
The question is if this is possible using combinations of Editors and TypeConverters.
Thanks.
Related
I have a DataGridTemplateColumn (created programatically) with a TextBlock for the CellTemplate, and a DatePicker for the CellEditingTemplate.
The DatePicker's value is bound to a DateTime?.
If the cell has a date when the grid is loaded, trying to clear the date results in validation problem -- the empty value is not sent to the bound property.
Is there a setting on the DatePicker to allow empty values (I couldn't find one)?
Is a converter needed to work with the nullable bound property?
Thanks for any insight --
I came across the same problem but it was with a textbox for entering quantity of the product. It had an integer as binded property. It used to act correctly with some quanity entered. But when the textbox got empty after entering some value, then the property had the previous entered value as its current value.
I resolved this by putting a string type property as binded property.
You can do the same. Bind a string type Property with DatePicker. As the date is being picked with DatePicker, you are always sure of the date format. Also you can make DatePickerTextBox as readonly in app styles to not let user input any date by typing.
And in this way when you clear the DatePicker, The underlying binded property will contain null or empty string and I think that is what you are wanting.
You can use that string property in
DateTime.Parse Method to get an equivalent DateTime Object. Try parsing the date in try catch block to handle empty/null string case.
I am trying to set up a reusable custom control with a combobox to be used with Bootstrap. The custom control has already all the divs, styles etc. that are needed for Bootstrap.
Now, I added a Property Definition (type: string, Allow multiple instances), so that when you use the custom control on any form, you can add selectable values to the combobox:
As a values property for the combobox, I added a computed item with the following JavaScript:
compositeData.listValues
When I use the custom control I can add values individually, one instance for one selectable value and it does work great:
However, when I compute the value to, lets say, get a list of values from a keyword document or view column:
the combobox value list looks like this:
How can I pass on a list of values thru property definition to the combobox? Is it possible at all?
UPDATE: Is there a way to loop thru the instances of a property definition? That way I could check if the current instance is a single text value or an array, put a list of all the values together and return it as a value list.
Thank you very much for your help!
In the Custom Control properties, next to Type, leave it as String and then click on the folder icon. In there you can choose complex types.
In there you can choose view column, among a vast array of choices.
UPDATE: David Leedy pointed out a caveat in regards to using comma as a separator for #Implode/#Explode. This could cause issues, if any of your values contains a comma. So, I amended my answer to account for that:
First of all, I'd like to thank everyone who took a look at this question and / or responded to it.
I had an epiphany this morning and found a solution. Might not be very elegant but it works.
As we are going to use #Implode/#Explode to build the value list for the combobox, we need to add another property definition to the reusable custom control. This property will be used to pass on the information, how the computed value list will be separated:
When I add values to the custom properties, the computed value for getting the list of values from a keyword document should look like this:
var oView:NotesView = database.getView('$vwSYSLookupKeywords');
var oDocument:NotesDocument = oView.getDocumentByKey('.DBProfile', true);
#Implode(oDocument.getItemValue('iTxtTest'),';')
As you can see, in this example I use ";" to implode the list.
This is now my list of Custom Properties:
And this is the markup for the whole custom control where I use the reusable custom control:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xc="http://www.ibm.com/xsp/custom"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<xc:ccLegend
listSeparator=";">
<xc:this.listValues>
<xp:value>Test 1</xp:value>
<xp:value>Test 2</xp:value>
<xp:value>#{javascript:var oView:NotesView =
database.getView('$vwSYSLookupKeywords'); var
oDocument:NotesDocument = oView.getDocumentByKey('.DBProfile',
true); #Implode(oDocument.getItemValue('iTxtTest'),';')}</xp:value>
</xc:this.listValues>
</xc:ccLegend>
</xp:view>
If I now use the following in my computed value list for the combo box:
var sSeparator = compositeData.listSeparator;
#Explode(#Implode(compositeData.listValues, sSeparator), sSeparator);
the values are properly displayed in the combobox:
This does also work with #DBColumn and #DBLookup!
If you have a better solution, please do not hesitate to post it here.
Did you try to set the property to object instead of string. That should allow you pass an array to the custom control with imploding and exploding it.
In my form I have a Barmanager, in which I have a comboboxedit1. I want to know how to access to the selected item of the baredititem1 (combobox). In the normal combobox it is:
dim q =combobox1.selecteditem
but I can't do the same in a baredititem1 wgich is placed in a barmanager.
You can grab the current selected value using the barEditItem1.EditValue property, or while the editor is activated, you can access the current editor instance by BarManager.ActiveEditor property, which you should cast to ComboBoxEdit in your case. You can read about this more in the documentation, where they explain why you cannot access the concrete editor anytime you want.
In my application's viewport i'm showing the form panel with a list of fields in center region and property-grid in east region.
I need to show the list of properties of the field in the property-grid on selection of the field.
The user is able to change the properties.
Now my requirement is to apply the properties dynamically to the field.
Is there any generic way to achieve this?
Can someone help me?
Some properties have getter and setter functions, but not all of them and I doubt they are consistent enough for what you are trying to do.
My suggestion would be to store the config object for each field, the config object would have each property that you want to be able to change using your property grid. When a property changes, remove the field from the form. Re-create it using Ext.create and passing your config object as the second parameter. Then just insert the object back into the form.
EDIT: You can probably skip using Ext.create by using the insert function on your form panel, it seems to be able to accept a config object directly.
In WPF using IDataErrorInfo and Style I want to create form where I can provide end user three different status while validating data
To make the scenario more clear
1) I have textbox next to it I have icon which provides end user what kind of input textbox expects - Initial status with information icon
2) As soon as user enter data it validates it and decides whether it is valid or not
- most of the time it will show cross (X) icon saying invalid data
3) As it is validating on UpdateSourceTrigger="PropertyChanged" it will turn cross icon to green check mark as soon as it gets validated
i.e
[ ] i (tooltip- Any valid user name )
[Ga ] X (tooltip- Invalid user name. Must be 5 char long)
[Gaurav ] * (it will show only correct icon, meaning valid value)
How can I achieve this using IDataErrorInfo and Style, I tried doing that but as soon as my form gets loaded it invalidates all the data and shows cross icon at the first time. I want to show different tooltip and different icon for three states (Initial info, Invalid data, Valid data)
IDataErrorInfo does not contain any means of representing three states. It only knows "error" and "no error".
The best solution may be to circumvent the use of IDataErrorInfo via the following:
Create a property for each validated field that provides the three-state status for its related field.
Bind ContentControls in the view to these three-state properties.
Set a single style for all of these new ContentControls.
Use Triggers in the Style to assign the ContentControl.ContentTemplate property for the error state and the valid state. For the initial state, use a Setter in the Style itself to display nothing.
You may also have to create properties for each field's tooltip text as well.
you can find a great example here WPF Apps With The Model-View-ViewModel Design Pattern