jQWidgets Forums

jQuery UI Widgets Forums General Discussions jqx (e.g DateTimeInput) & MVC EditorFor

This topic contains 5 replies, has 3 voices, and was last updated by  Peter Stoev 10 years, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • jqx (e.g DateTimeInput) & MVC EditorFor #12835

    Ernst
    Member

    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?

    jqx (e.g DateTimeInput) & MVC EditorFor #12840

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    jqx (e.g DateTimeInput) & MVC EditorFor #12843

    Ernst
    Member

    Thanks 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 then 🙁

    jqx (e.g DateTimeInput) & MVC EditorFor #12845

    Peter Stoev
    Keymaster

    Hi Ernst,

    Thee is no way to use at least the MVC’s EditorFor method, because it works with different tag.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    jqx (e.g DateTimeInput) & MVC EditorFor #67415

    Hi Peter,

    Do you plan to release a patch so that jqxCalendar can be binded to MVC model?

    Best Regards,
    Lingesh

    jqx (e.g DateTimeInput) & MVC EditorFor #67416

    Peter Stoev
    Keymaster

    Hi 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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.