jQWidgets Forums
jQuery UI Widgets › Forums › General Discussions › jqx (e.g DateTimeInput) & MVC EditorFor
Tagged: jqWidgets MVC editorfor template
This topic contains 5 replies, has 3 voices, and was last updated by Peter Stoev 10 years, 5 months ago.
-
Author
-
To start: I’m familiar with jQuery, but new to both MVC 4 and jQWidgets, so I might miss the obvious.
I want to create a default Date input to use in my project, bound to models.
Using the jQuery calender, I can do this as follows:Shared/EditorTemplates/Date.cshtml
@inherits System.Web.Mvc.WebViewPage<System.DateTime>@Html.TextBox("", (Model.ToShortDateString()), new { @class = "datePicker" })
And in my modelbound view:
<script type="text/javascript"> $(document).ready(function () { $('#StartDate').datepicker("option", "maxDate", "+0"); $('#EndDate').datepicker("option", "maxDate", "+1"); });</script> @Html.EditorFor(model => model.StartDate) @Html.EditorFor(model => model.EndDate)
Since jQuery can use textinput fields, this works like a charm.
As far I’ve seen, jQWidgets uses divs, and I cannot seem to bind it to text inputs, but I would really like to use your DateTimeInput widget in my views.
How would I achieve this in a similar generic way as in my example so I can use the native MVC model checks etc?
P.S. is there a wysiwyg editor for this forum or a preview function?
Hi Ernst,
– You will not be able to use the EditorFor method, because it expects Input tag, not a DIV tag. You can use our DateTimeInput widget in the way demonstrated in our samples and help documentation.
– The Forum software which we use has only html editor. However, you can use the toolbar for generic formatting and code formatting.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks for the fast reply!
Yes, I saw the samples, but was hoping there would be a work around.
So, basically, there is no way to bind your widget to the standard model validation in a generic reusable way?
Guess I’ll stick with jQuery’s datepicker thenHi Ernst,
Thee is no way to use at least the MVC’s EditorFor method, because it works with different tag.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Do you plan to release a patch so that jqxCalendar can be binded to MVC model?
Best Regards,
LingeshHi Lingesh,
The widget works perfectly well with MVC and can be used in the Documented way. However, it requires DIV tag and this is how it will be in future versions, too.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.