We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

New Row with pre determined date

Hello,

I have a grid that uses InlineTemplateForm with JSON.
Here is my templateform 
@model ICD9Model
<fieldset>
    <b>ICD9 Details</b>
    @Html.TextBoxFor(model => model.ID, new { style = "display:none" }) 
    <table class="table-container">
        <tr>
            <td>
                <table class="content-left">
                    <tr>
                        <td>
                            Date
                        </td>
                        <td>
                            @Html.TextBoxFor(model => model.Date)
                            @Html.ValidationMessageFor(model => model.Date)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Diagnosis <a rel='nofollow' href="javascript:void(0)" onclick="SearchOpen();">(Select ICD9)</a>
                        </td>
                        <td id="icd9_details_diagnosis">
                            @Html.TextBoxFor(model => model.Diagnosis) 
                            @Html.ValidationMessageFor(model => model.Diagnosis)
                        </td>
                    </tr>
                </table>
            </td>
    </table>
</fieldset>


Is there a way I can specify the Date to be Today's date when the user clicks on Add New Item?


3 Replies

SK Shanmugaraja K Syncfusion Team February 28, 2014 08:42 AM UTC

Hi Steven Sinakhot,

 

Thanks for using Syncfusion products.

 

We would like to let you know that your requirement has beed achieved by handling OnActionSuccess client side event. Please refer the below code snippet to achieve your requirement.

 

[JS]

 

<script type="text/javascript">

    function success(sender, args)

    {

        if (args.RequestType == "AddNew")

        {

            $("#GenericListGriddate").val($.datepicker.formatDate("yy-mm-dd", new Date()));

        }

       

    }

</script>

 

Please refer the below attached sample for further reference.

 

Please let us know if you need further reference.

 

Regards,

Shanmugaraja K


Attachment: templateform_dc676572.zip


SS Steven Sinakhot March 5, 2014 06:41 PM UTC

It works perfectly. Thank you.


SK Shanmugaraja K Syncfusion Team March 6, 2014 06:40 AM UTC

Hi Steven,

Thanks for your update.

We will wait to hear from you.

Please let us know if you need further assistance.

Regards,
Shanmugaraja K

Loader.
Live Chat Icon For mobile
Up arrow icon