ej-autocomplete passing text not value - autocomplete

I am trying to write a control that takes a list of names, allows the user to select from this list and then posts back the username for the name that has been selected.
Firstly, I used a Syncfusion ejDropDownList control to accomplish this, where the code I used was:
<ej-drop-down-list id="UserList" datasource="(IEnumerable<User>)ViewBag.Users" ej-for="Username">
<e-drop-down-list-fields text="Name" value="Username" />
</ej-drop-down-list>
This works fine and when I submit the form, the Username field is bound correctly in the associated model.
Since there are too many names in the list to realistically use a drop-down list, an autocomplete control is preferable.
However, when I implemented the control in the following manner:
<ej-autocomplete id="UserList" datasource="(IEnumerable<User>)ViewBag.Users" ej-for="Username" filter-type="Contains">
<e-autocomplete-fields text="Name" value="Username" />
</ej-autocomplete>
Then the 'Username' value in the model is bound to the 'Name' field.
Is anyone familiar with Syncfusion controls who can tell me how I can bind the selected value (as opposed to the selected text) to the 'Username' column successfully?
Thanks,
Sean

Syncfusion Autocomplete not have a field type of value. You can also use Key field for your scenario.<ej-autocomplete id="UserList" datasource="(IEnumerable<User>)ViewBag.Users" ej-for="Username" filter-type="Contains">
<e-autocomplete-fields text="Name" key="Username" />
</ej-autocomplete>
refer the documentation link: https://help.syncfusion.com/aspnetmvc/autocomplete/data-binding

Related

Can we hide system default fields from workItem form?

Can we be able to hide the system defaults fields on the workitem form?
For TFS 2017, On-premises XML process model: You can modify select elements within the SystemControls section, such as changing the EmptyText attribute value for the System.Title field. In general, we recommend you don't customize this section much more than that. For example, you can't remove fields from or add other fields within this section.
For TFS 2018, On-premises XML and Azure DevOps Services, Hosted XML process models: You can specify the ShowEmptyReadOnlyFields attribute, or select to hide or replace select fields defined within the SystemControls section.
For example, to hide the Reason field, you modify the Control element with the Visible attribute.
<Control Label="Reason" Type="FieldControl" FieldName="System.Reason" Visible="false" />
To replace the Reason field with another field, use the Replaces attribute. Also, remove the entry for the Reason field from within the section.
<Control Label="Milestone" Type="FieldControl" FieldName="Fabrikam.Milestone" Replaces="System.Reason" />
See more info in the docs.
If the process you are using is a custom process inherited from the template process, normally you can't hidden the default fields.
If your process is defined using a XML process model, as #ShaykiAbramczyk suggested, you can try to edit the XML file for the process definition to hidden the fields.

Setting a default list of items in project_attribute in a GNAT GPS Plugin

I'm working on a custom GNAT GPS plugin (for GPS 6.1.2).
My plugin XML creates a project attribute "example_list_of_files".
This is a list of strings, that correspond the names of Ada files in the project.
I want to default the entries in that list to "a.adb","b.adb","c.adb". However I've been unable to find the correct syntax for this. Instead i end up with a single string of all the values.
What i want to see is what happens when you manually add three elements, as shown below:
Here is the code for this example:
GPS.parse_xml('<?xml version="1.0" ?>' + """
<my_plugin>
<project_attribute
name="example_list_of_files"
label="example_list_of_files"
description="A description...."
package="MyPackage"
editor_page="MyPage"
editor_section="Build"
hide_in="wizard library_wizard"
omit_if_default="false"
list="true"
base_name_only="true">
<string type="file" filter="project" default="'a.adb','b.adb','c.adb' " />
</project_attribute>
</my_plugin>""");
Notice the string element with the project attribute default. Instead of a list of entries in the project manager it gives me a single entry, containing the string "'a.adb', 'b.adb', 'c.adb'".
Anyone got any ideas? I've also tried multiple string elements, adding brackets, braces, square-brackets, space separators, prefixing with 'array(' with no luck.
thanks
Matt
It seems indeed this is not supported. The standard plug-in projects.py has several list attributes, but all of them have a single value as the default. I'll check what can be done to improve here.
However, your approach might be wrong in the first place. The default you are setting only concerns the project editor. That means that if a user uses a default project (like project default is end default) and never goes through the project editor, your attribute example_list_of_files will in fact not exist (and have a default empty value). So it seems that this should in fact be handled in your plug-in, when you query the value of the attribute (like via GPS.Project.get_attribute_as_list). If that function returns an empty list, then use ("a.adb", "b.adb", "c.adb") instead. That way, things work fine even with a default, unedited project.
From the GPS User's Guide:
The tag accepts the following attributes:
[...]
list (boolean, default false)
If true, the project attribute contains a list of values, as opposed
to a single value. An example is the list of source directories in
standard projects.
In your example:
<string type="file" filter="project" default="'a.adb','b.adb','c.adb' " />
This is a single string value. Instead, you should specify a list of string values, like this:
<string type="file" filter="project" default="a.adb" />
<string type="file" filter="project" default="b.adb" />
<string type="file" filter="project" default="c.adb" />

grails access form attributes in controller

In grails i have a form with g:field tags like:
<g:field name="test" from="0..20"/>
I am trying to find a way how I can access the "from" attribute in my controller.
I can get the "value" attribute by using:
print params.test
I have tried:
print params.test.from
I'm sure there must be a way to do this but I can not seem to find it.
What I am wanting to achieve by this is perform validation so that the value does not go outside the the from range.
I know that this can be added in the domain, but in my situation I need to allow the user to overwrite the range constraints.
Any ideas?
By the time that code hits the browser, it is just HTML. from doesn't exist anymore. If that is being rendered into some sort of client side validation, that's not going to get submitted back to the server in a form submit.
If you explain what you are really needing to do in your question, I can provide a better answer.
You can pass the "from" values as hidden fields.
<g:hiddenField name="min" value="0" />
<g:hiddenField name="max" value="20" />
Something like that.

How to retrieve text from RichTextBlock in WinRT

I am using the standard RichTextColumns.cs helper class that is added by VS2012's default Metro Style project template. It uses the RichTextBlock internally to add RichTextColumns. DataBinding is working fine with the following markup
<common:RichTextColumns>
<common:RichTextColumns.ColumnTemplate>
<DataTemplate>
<RichTextBlockOverflow Width="400" Margin="50,0,0,0"/>
</DataTemplate>
</common:RichTextColumns.ColumnTemplate>
<RichTextBlock Width="400">
<Paragraph>
<Run Text="{Binding Content}"/>
</Paragraph>
</RichTextBlock>
Now I have the embedded hyperlinks in 'Content' that are not treated as hyperlinks in WinRT. I need them to behave like hyperlinks. So I want to retrieve the text that's getting bound to the RichTextBlock, tokenize it, insert InlineUI elements that have the HyperlinkButton at appropriate places. Now I could do all this if I could only retrieve the text that is getting bound to the RichTextBlock. Unfortunately I can't seem to 'retrieve' it.
I tried
RichTextBlock value = (RichTextBlock)GetValue(RichTextContentProperty);
valueRun = (Run)((Paragraph)value.Blocks[0]).Inlines[0];
value.Select(((Paragraph)value.Blocks[0]).ContentStart, ((Paragraph)value.Blocks[0]).ContentEnd);
Paragraph para = TokenizeTweet(value.SelectedText);
But the SelectedText is always empty.
However if I do a
value.Blocks.Clear()
it clears out the text that is getting bound. What am I missing?
Simply put, how to retrieve unformatted text from a RichTextBlock in WinRT (Not WPF or Silverlight).
Thanks and Regards,
Sumit.
Instead of trying to retrieve it, why not simply use a converter on the binding?

How to display different value in struts 2 select

I want to know how to display a different value in struts 2 select.
eg: i want to put Jan,Feb as month where the value should pass 1,2 respectively.
if anybody aware of this please let me know
thank you.
See the following example (from the Struts 2.1.8 API doc) :
<s:select label="Months"
name="months"
headerKey="-1" headerValue="Select Month"
list="#{'01':'Jan', '02':'Feb', [...]}"
value="selectedMonth"
required="true"
/>
The list attribute contains a map where the key is the value that will be sent and the value is the value that will be displayed.
Of course, months are static, but you could use a list of domain objects or whatever beans you need. In this case the list should be stored, typically as a field of your action class. Then you will refer to the list or map :
<s:select label="User"
name="users"
headerKey="-1" headerValue="Select User"
list="users"
value="selectedUser"
required="true"
/>
In this case your action will contain a map with the usernames and their ids and a getter for it : getUsers().
If the getUsers() method of your action returns a list of User objects, and the User class has at least (let's assume) the id and username fields, you will have to specify which field to use for value to be passed and which field to use for display in the select. This is done with the listKey and listValue attributes of the select tag :
<s:select label="User"
name="users"
headerKey="-1" headerValue="Select User"
list="users"
listKey="id"
listValue="username"
value="selectedUser"
required="true"
/>