I'm trying to implement kendo.ui.NumericTextBox (
http://docs.kendoui.com/api/web/numerictextbox#downarrowtext-stringdefault)
in a similar manner to the other jquery ui elements. I've included the
necessary basics for the kendoui stuff ie the kendoui-rails gem and added
all that is required for it. Now I'm trying to create a rich data type and
implement the numerical text box using the jquery ui calendar control.
First things first the rich data type below seems to work find when I add
it to a field of a model
class Currency < DelegateClass(BigDecimal)
COLUMN_TYPE = :decimal#, :precision => 12, :scale => 2
HoboFields.register_type(:currency, self)
def to_html(xmldoctype = true)
"$#{number_with_precision self, :precision => 2}"
end
end
I wish I could specify the precision and scale here but that doesn't work
the last I checked so I need to have the field in the model setup as:
cost :currency, :precision => 12, :scale => 2
But it works so moving on.
My problem is in setting up the tag to go along with the rich type. I have
the following so far based again on the jquery calendar tag
<def tag="input" for="Currency">
<currency format="c" decimals="2" merge/>
</def>
<def tag="currency" attrs="name"><%
options, attrs = attributes.partition_hash(['culture', 'decimals',
'downArrowText', 'format', 'max', 'min', 'placeholder', 'spinners', 'step',
'upArrowText', 'value'])
events, html_attrs = attrs.partition_hash(['change', 'spin'])
add_data_rapid!(html_attrs, "kendoNumericTextBox", :options => options,
:events => events)
name ||= param_name_for_this %>
<%= text_field_tag(name, this, deunderscore_attributes(html_attrs)) %>
</def>
Two issues so far.
First the first tag isn't get used by default for currency fields.
If I work around it by manually calling the second tag as per below the
input tag looks fine but the kendoNumericTextBox function is never called
to convert the standard text box over. I don't see how that is done for
the calendar control.
Work around to manual call the second tag
<field-list size="8" columns="2" fields="price, cost">
<cost-view:><currency/></cost-view:>
</field-list>
Any help in understanding all this would be appreciated. I hope to add a
few other kendoui controls once I figure out how this all works. I'll of
course make it all available as a gem for others to use assuming I ever get
it working properly.
Bob
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/hobousers/-/t1bE0XQt6BgJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.