Ext JS 4 - how to add a time stamp to a text area form field? - forms

I have an form with a text area field. I want to add some text (a date/time stamp) when the user clicks in to the form. I am assuming I need to catch a click type event when the user clicks in to the field and then edit the field value and insert the text I want. Is this the best approach?
Looking for suggestions based on using Ext JS 4 / MVC.

As mentioned by you - "I need to catch a click type event when the user clicks in to the field" - One way to achieve this and appending of timestamp to the value could be by using the focus event in following manner:
focus:function(){
var value = this.getValue();
value += new Date().getTime();
this.setValue(value);
}
Just that the date used here is the client's system date.
Hope this helps.

Related

PowerApps - autofill date for newform

Using PowerApps, how can I get the current date to be autofilled into a new form?
Does the code go into the IconNewItem1 function from the parent BrowseScreen1?
NewForm(EditForm1);Navigate(EditScreen1,ScreenTransition.None)
as something like ...
BrowseGallery1.Selected.Date = Now
Or does the code go in the EditScreen1 / EditForm1 area as a rule?
Any guidance or suggestion would be appreciated.
You would do that in the form itself (or the date picker control of the form). Select the card that has the date value, and in the right-side pane select the 'Advanced' tab. You'll need to unlock the card to change the properties, and when you do, change the Default property of the card from
ThisItem.DateTimeColumn
to
If(EditForm1.Mode = FormMode.New, Now(), ThisItem.DateTimeColumn)
Where DateTimeColumn would be replaced with the name of the column in your data source, and EditForm1 would be replaced with the name of the form control.

Form submit button to email based on a fields value

I'm creating a PDF form with a submission button. I would like the form to email based on the value of another form in the field. I'm assuming I need to do an "IF...ELSE" statement, but keep getting a syntax error that I cannot figure out. I am completely java illiterate.
This can be done using multiple solutions, but you do need to program Javascript inside of the PDF. You can use if-else on-click of the email-button. Here you can check values entered inside of the PDF form:
if (this.getValue("somefield") == "left") { emailvalue = "toA#domain.com" } else { emailvalue = "toB#domain.com" }
But you could also set the value onBlur or onFocus of a certain field. Like with radio-buttons the onBlur is useful because you know the user clicked or focused on this field and so set the variable emailvalue to a certain value.

Zope form : adding a button to automatically fill some fields

under Plone4/Zope3, I have a form to add a new object.
I'd like to add a button after the first field, to do the following :
- the user enters the value for the first field
- he presses this new button
- and the server will try to guess the remaining field based on the first field and an external database.
- the user will then have to check if all fields are OK and then submit the form.
I am not a zope expert, and spent some time trying to figure out how to do this.
Is creating a subform a good idea ?
If not, I could add a new button to the form : I tried something like
#button.buttonAndHandler(_(u'Essai'))
def essai(self, action):
print "button essai"
but then I have the following issues :
- how to render the button after the first field and not at the bottom ?
- how to update the remaining fields without submitting the form ?
- how to keep the "add" and "cancel" button that disappeared when I added this essai button.
any hints ?
Thx
I suggest to use javascript to solve this. With jquery you can include an extra button directly behind your first field (http://api.jquery.com/after). In the button action ask a browser view for the search results in json (http://docs.python.org/library/json.html) an fill up the other form fields, like:
jq('my-button').click(function(event) {
event.preventDefault();
var first_field= jq('#first-field-id').val();
jq.getJSON('/##my-browser-view?value=' + value, function(result) {
jq('#other-field-id').val(result.val_for_other_field);
...
});
});

SmartGwt DateItem useTextField=true - how to make text entry field UNeditable

Since I can't figure out how to solve my problem presented here I'm thinking for the moment at a temporary solution.
I have a smartgwt DateItem widget:
DateItem date = new DateItem("Adate");
date.setWidth(120);
date.setWrapTitle(false);
date.setAttribute("useTextField", true);
date.setAttribute("inputFormat", "yyyy/MM/dd");
date.setAttribute("displayFormat", "toJapanShortDate");
Because the attribute useTextField is set to true we can see the text entry field. How can I make this text entry field to be uneditable.
Actually I want to have only the possibility to choose the date from calendar and not to change it manually.
Resolved - the issue exposed above - thanks to #RAS user.
TextItem textItem = new TextItem();
textItem.setAttribute("readOnly", true);
date.setAttribute("textFieldProperties", textItem);
Related link
But I have now another issue (resolved - see here):
The date chooser won't show the date on the text field but Today's date.
For example, enter 30/05/2009 on the text field, go to another field, then come back on click on the date chooser and the selected day will be Today's date instead on June 30th, 2009. Which is the reason for this? Can this be solved?
Also let's say I let to the user to opportunity to manually modify the date - can I put some **validators on it?** (still need an ideea on this)
Thank you.
date.setEnforceDate(true);
http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/form/fields/DateItem.html#setEnforceDate%28java.lang.Boolean%29
You have a lot of different validators. Depending on the context it must be possible to validate cardinality, relation to other data items, datatype(not only date time values) and relations to other external records.

Dynamic JQuery date picker code

I need to create dynamic filter that adds/removes rows dynamically.
It contains a drop-down box. Depending upon the drop-down box value selected, I create a dynamic <TD> that may have a text field or drop-down list.
If it's a text field, then I have to add date picker for that text field.
I have done this, except date picker for dynamically generated text field.
If you're creating 100 rows, the text fields' names should be same for all rows.
How to add datepicker for dynamically generated text field?
I had the same issue.
You would need to rebind the DatePicker to the dynamically added row.
The date picker associates a hadDatePicker Class to the dynamic row.
So you would need to remove that and rebind.
Something like this -
jQuery('.date-pick').removeClass('hasDatepicker').datepicker({
dateFormat: 'mm-dd-yy'
});
Regards,
Tina Agrawal
Actually i did use the solution provided by #Tina Agrawal But since now, when i select a date from the calendar, i click again and re-select. If i click on next month, it will go to 1900-01-01.
Well it was so strange...
After two hours of trial and errors and research.
i simply did:
$('.date-pick').live('click', function(){
$('.date-pick').datepicker();
});
Well it works.
I had the same issue and solved it in a different way. Although I am not very sure why is it working as I am very new to jquery. I wrote the following and it iterates the entire set of controls having the class "class_date" and rebinds the datepicker control to it.
$(".class_date").removeClass('hasDatepicker').datepicker();
Tirst add a class attribute as "date" to your input or div.
After dynamically add a text input to have to recall $('.date').datePicker() again to bind datePicker to new inputs or div.
I had a similar problem in that when dynamically adding new rows to my table the Date Picker fields in the new rows (any row added to the DOM dynamically) were all updating my initial rows Date Picker fields.
Removing the hasDatepicker class as suggested above was not enough to solve my issue, probably as I was using .clone() to create my dynamically added rows.
The solution when cloning rows was to remove the cloned input fields, re-create them, add them to my newly cloned table row and THEN re-initiate the Date Picker
For example:
//Remove exisiting cloned input fields
new_row.find("td.date input").remove();
//Create new input fields and append to table td
var date_tds = new_row.find("td.date");
$('<input />', {"name":"gStartDates["+n_array_pos+"]","type":"text"}).appendTo(date_tds[0]);
$('<input />', {"name":"gEndDates["+n_array_pos+"]","type":"text"}).appendTo(date_tds[1]);
//Re-initiate datepicker on the input fields
new_row.find("td.date input").datepicker({
dateFormat:"dd-mm-yy",
minDate:StartDate,
maxDate:EndDate
});
Use JQuery Live to access the dynamically created DOM.
http://api.jquery.com/live/
The you can attached the picker.
http://jqueryui.com/demos/datepicker/
one should use ".on" instead of live - see
http://api.jquery.com/on/