I have 5 fields on my screen. I work on 9300 not a touch device
-------- ---------
1 2
-------- ---------
------------------------
3'/3''
-------------------------
4
------------------------
I want when I click field 1 the focus change to the field 3'and if I click field 2 the focus change to field 3''. And when I click the down button the focus change to field 4.
What I have know the focus was in field 1 then 2 then 3''. I can't access to field 3' or pass to field 4.
How can I order the focus of fields
thanks
The order that the focus is transferred through your fields is normally determined by the order in which you add() them to their containing Manager.
You didn't completely specify how all of the transitions should work, but something like this might work:
public void MyManager(long style) {
super(style);
Field one = new LabelField("hello");
Field two = new BitmapField(image);
Field threePrime = new EditField("");
Field threeDoublePrime = new EditField("");
Field four = new LabelField("goodbye");
add(one);
add(threePrime);
add(two);
add(threeDoublePrime);
add(four);
}
If you want something more complicated than this, you can override navigationMovement(int,int,int,int) in your custom Manager subclass (the Manager that contains these five Field objects).
See this post for information about that technique.
Related
So I have a standard Kendo grid in MVC with 2 non-editable columns. What I would like to achieve is to enable editing of all columns only within the newly added rows.
Example: There's 4 rows already in the grid, first 2 columns non-editable. User clicks "Add new", a new record appears in the grid with everything editable.
Try adding an editable function handler to your column definition, something like this:
{
field: "salary",
editable: function (dataItem) {
return dataItem.isNew();
}
}
Please note: you will need to have specified an id column in your model definition for this to work, for details see isNew documentation:
Checks if the Model is new or not. The id field is used to determine if a model instance is new or existing one. If the value of the field specified is equal to the default value (specified through the fields configuration) the model is considered as new.
I have a listgrid which has 4 columns. Code,Name,Qty and Price. the name cell is a Combo Box which loads the names via datasource. So far all is fine. now i want to be able to enter a code in the Code col cell and then i want the Combo box to display the name in the Name cell and the corresponding Price in the Price cell. Can somebody help me to achieve this.I have attached a screenshot to make things more clear.
cheers
Zolf
You can add ChangedHandler/BlurHandler on Code field which will be invoked when user has entered the Code and try to navigate to the next field.
Within the event handler, you need to wirte your logic to set Name and Price based on Code value.
listGrid.getField("Code").addChangedHandler(new ChangedHandler() {
#Override
public void onChanged(ChangedEvent event) {
Record r=listGrid.getRecord(event.getRowNum());
String code=(String)event.getValue();
//add your logic to get Name and price based on Code value here
r.setAttribute("Name", name);
r.setAttribute("Price", price);
}
});
I'm using simple_form. How can I have a select menu and a text input and have something like Select or add another.
The app will only take one value, either from the select menu or the text input.
It would also be good to validate to have either one or the other but not both, to avoid user confusion.
Implement what is called a 'combobox' to your simple_form
Jquery UI has a combobox:
http://jqueryui.com/autocomplete/#combobox
something fancier:
http://demos.kendoui.com/web/combobox/index.html
This will get you as far as your combo boxes displaying. I don't think there is a plugin for validating, so you'll have to write the code yourself.
You can try to use a combination of JavaScript and Ruby to solve this. If a user wants to enter a different value then what's available in the dropdown, you should have JS listen to a keydown event in that input and clear the dropdown, i.e.:
$(".input_field").bind('keydown', function() {
$(".select_field").val('0') // this should be a default blank value
});
That will clear the select when a user types. Likewise, you want to clear the input when the user selects from the dropdown, right?
$(".select_field").change(function() {
// Let's only clear the input field if the value is not the default null value
if ( $(this).val() != 0 ) {
$(".input_field").val('');
}
});
This will handle the front-end interactions. In the controller, you'll want to do some additional logic:
def create
object.new(...)
if params[:select] and params[:input]
# Overwrite the select with the input value
object.attribute = params[:input]
end
object.save
end
I assume that you want the input value to supersede the select, therefore if they are most submitted, we can just overwrite the select value with the input value and then continue to save the object.
Is this what you're looking for? Not sure if the inputted value was suppose to create a new object with a relationship or not. Hope this helps.
I have a Telerik grid in my asp.net mvc application that looks something like:
Now it lists all the regions in a zone selected from the list placed just above the grid. zoneid is foreign key in the grid. Now I want that when I add new region in the grid the zoneID should be taken from the list instead of what is present in zone column of the grid because that value is just to display the zone and that can also be removed from the grid as it as apparent from the list which zone the listed regions belong to.
I understand that I could have used editor templates to show this list inside the grid on edit but I prefer it to be outside the grid and provide some filtering on basis of the zone as we are likely to have many regions per zone. so my concern here, now, is how can I set ZoneID of a region (edited or newly added) equal to selected value of list that shows just above the grid control.
When you click on the AddNewRecord button, why don't you set the Value of your zone equals to the zoneId selected in the combobox value ?
I've done something a little similar, but I had to get the value from a Treeview.
private void btnAddContact_Click(object sender, EventArgs e)
{
Int64 companyId = Int64.Parse(treeCompany.SelectedNode.Name);
dsSociete.ContactRow newContact = dsSociete.Contact.NewContactRow();
newContact.SocieteId = societeId;
dsSociete.Contact.AddContactRow(newContact);
}
And once i add a new Contact, it gets automatically its Company (Societe is Company in French) set.
I did it in Winform, but I guess you can do the same in Web?
I solved this problem by hooking the onSave event of Telerik grid like
<%
Html.Telerkik.Grid<xyz.company>()
.Name("name")
.// other properties
.Events(even=>even.onSave("onSave")
.Render();%>
Inside onSave event handler in JS I have written something like
function onSave(e)
{
var data = e.values;
data["companyID"] = $("#CompanySelectList").val();
e.values = data;
return true;
}
onSave event adds the companyID at companyID index of json that will be submitted to the server and modelbinder will bind it with concerning property name of model.
What would be the easiest way to have the color of a text field in an ASP .NET MVC form changed according to a value just entered BEFORE form submission.
The color to be used is returned by a DB query.
For example:
The query returns Red if the number enter in the field is lower then the Quantity registered for the item in the DB.
Thanks
You can do it like in the example below, using jQuery :
//bind a function to the blur even of the text field
$("#the-imput-control").blur(function () {
var value = this.val();
//send the value to the server and then process the result.
$.getJSON("yourUrl", { key: value }, function(data) {
//return a json object with a property "color"
//and use its value to set the text field's color
$("#the-imput-control").css("color", data.color);
});
//you can of course use another ajax function depending on your needs.
});
You would like to have an event onclick for the submit button or on changing the quantity to retrieve the quantity of the product.
You can also load a color in the beginning but the stock may change during the user's input.
For example
User loads an order form, quantity in stock: 4, maybe you set the color to orange because it's low...
user fills out the form, some other users order 3 in total, 1 is left in stock
user would like to order 2 items.
user clicks on submit, you have your event checking the quantity and display a message/change the color of textbox
As I understood you would not have a postback if the amount in db is lower than the amount ordered.... but consider that users may not have javascript turned on, you should also implement in server side.
Personally I would just do it on server side, because on client side is just an extra functionality which you cannot rely on.
If it doesn't impose any security risk, it would be best to cache the available quantity for the products, instead to go to the server for validation. This way, the UI will be more responsive - and the user experience will be better. So, basically,
// JS
var availableQuantities = [10, 15, 30];
$(".the-imput-control").blur(function () {
var value = $(this).val();
var productIndex = $(this).parent().children().index(this); // sort of
$(this).toggleClass('invalid', (availableQuantities[productIndex] < value));
});
// CSS
.invalid { color: red; }