Issue with masked textbox for website address using kendo ui - asp.net-mvc

I am using kendo ui to for the masked textbox. I am done with phone number and fax number. but i want to put "http://_________________" for website textbox which should be variable length string. How can i achieve that?
I used following way to achieve phone number.
#(Html.Kendo().MaskedTextBox()
.Name("phone_number")
.Mask("(999) 000-0000")
.Value("555 123 4567")
)

For the time being, the MaskedTextBox widget works only with strict mask length. In other words, the widget's mask defines the length of the input, which cannot be dynamic.
I am afraid that this is a limitation with the widget and there is no feasible workaround for it.
You can vote for this functionality here:
Kendo UserVoice discussion

Related

How to get leading zeros displayed in the Vaadin DateTimePicker component?

In my Vaadin Flow application, I'm using the Vaadin DateTimePicker component. If I select a date, it will be displayed without the leading zeros (e.g. "4.7.2021"). I would like the component to display the leading zeros (e.g. "04.07.2021"), but I could not find an API call to do so. Locale is Switzerland. Any ideas? I guess I'm missing a really easy solution to this all-day-problem…
You should use the EnhancedDatePicker https://vaadin.com/directory/component/enhanced-datepicker
There you can set pattern and even parsers. For example:
// how the date should be formatted
datePicker.setPattern("dd.MM.yyyy);
// allowed formats to enter the date
datePicker.setParsers("ddMMyy", "ddMMyyyy", "dd.MM.yy", "dd.MM.yyyy");

Auto page break in libHaru PDF

I'd like to add an automatic page break to a libHaru PDF in iOS.
I do have several text fields in the app which contain the user filled data. when i generate the pdf i first measure the expected size of the text-rect going to be created. if it exceeds the remaining space i trigger a hpdf_new_page event and put the text on an new page. i'd like to have this just in part automatically. so if the text exceeds the space on the current page it should split and continue on a new page without me checking or doing anything.
unfortunately i can't find anything like this in the documentation.
Line counting using fgets() may help. When your print program opens a file to print, each line can be copied to the pdf file and checked for a form feed character
or
if the line count has reached a limit.
Another possible solution is to use a character count limit with "while(getc(file) != EOF)".
This link uses libharu to print basic text files with PCL commands to change the font.
https://github.com/DaDaDadeo/GetCycle/blob/master/pcl_to_pdf.c
The form feed character '\f' (ascii 12) and 61 lines will trigger a new page. There are other conditions in the program to restrict a new page but the general idea is illustrated.
The results are the same as a printer using telnet raw 9100 protocol. The pcl commands are limited to just a couple of font changes so it is not too complicated.
Libharu is rather low-level library, and I could not even expect of appearing such automatic page splitting in newer versions due to number of reasons. Hereafter I state two of them:
There is no good, preferred strategy how to place remaining of non-fitting text on the next page. In some cases it could be even impossible at all.
There is no good, preferred strategy for text splitting.
Why?
Consider your font is extremely large, and just one letter (for instance, wide one as "W") does not fit into the page. Where we are supposed to place it? On the next page? Ok, we add new page... oops, it does not fit this page too - as soon as all our pages have the same size. Dead-end without any good, straightforward way out.
In other words, there should be a user-defined strategy for these cases. Almosy every naive implementation will have such a corner cases.
libharu does not know where it should split your text automatically. It does not know hyphenation rules of your language, it does not know whether it should respect spaces or not (wrap whole words only or not), and so on. It's up to you to specify these rules.
So, you should call HPDF_Font_MeasureText for some part of your text string, decide if it fits into your page (excluding margins, footers - which also out of libharu's internal knowledge) and render it. And note that there is no simple formula for text size depending on its length. String "wwww" is more than twice wider than "iiii", of course if your font is not mono-spaced.

FormatFloat in Livebinding

I'm currently trying to use XE5 livebindings to bind a TTrackBar.Value property to a TLabel.text property. The TrackBar has a frequency of 0.1. Unfortunately, what I'm finding is that with the binding in place, the label is displaying increments that aren't exactly 0.1.
For example, if I set the livebinding links 'CustomFormat' property to %s+'x', the label will sometimes display the extended float value, so instead of say displaying 0.6, it'll display something like 0.6004874613100 which makes the UI look messy.
I am aware of the FormatFloat routine, but unfortunately this isn't accepted by the CustomFormat field in the link itself.
Is there any way to format the value so it only displays the short version (i.e. 0.6) instead of the extended value? I know I could manually code it in, but I've got several components in a similar situation and I'd like to use livebindings where possible.
You can use something like Format('%%.1f',%s)
See Mike Sutton's answer here on SO: Using Format in a livebindings CustomFormat

Is it possible to convert a simple radtextbox to radnumeric-textbox

Is it possible to convert a simple radtextbox to radnumeric-textbox from codebehind or javascript? I have a dropdown list where i can decide whether the text box should allow only numbers or any character.
You can utilize RadMasked Textbox for that purpose.
Simply take RadMaskedTextbox and manipulate the mask according to your requirement in code behind or in javascript.

Grails - How to format a value in a textfield into comma style such that it can be easily read?

I want to allow users enter numbers in textfield and once the textbox loses focus. The number is formatted with commas.
e.g. User enters 100000
textfield looses focus
value displayed: 100,000
How can I achieve this in Grails.
I have looked at
<g:formatNumber number="${myNumber}" format="\\$###,##0" />
But it doesnt solve my problem as the number is from a textfield.
thanks
Much appreciated.
Well, you have to understand the difference between code that is executed on the server-side vs. client-side scripting. Your requirement "once the textbox loses focus" just can't be met by Grails, because detecting focus loss of DOM elements and reacting to it happens entierely in the user's browser. You will have to do this in JavaScript (which isn't a big deal either). For example these two jQuery plugins should do the trick (but there are plenty of other solutions, also for other JS libraries).

Resources