Asht T

Asht T

  • 1.3k
  • 333
  • 11.1k

How to add datetimepicker inside datatable......

Jul 19 2022 4:21 AM

How to add datetimepicker inside datatable......

My code is like following but this is not working

 var RegObj = {
                        ENNo: $('#txtENNo').val()
                    }

 

 var RegObj = {
                        ENNo: $('#txtENNo').val(),
                        ApprovalID: ApprovalID
                    }

                    // $("#LoadingImage").show();
                    $(function () {
                        $.ajax({
                            type: "POST",
                            url: '@Url.Action("SetInstDatatable", "SRegInstallment")',// "/RptStudOMSStudent/GetReportDetails",
                            // data: "{'AcadYear':'" + AcadYear + "','CourseID':'" + CourseID + "','BranchID':'" + BranchID + "','ClassID':'" + ClassID + "','DivisionID':'" + DivisionID + "','CType':'" + CType + "','CategoryID':'" + CategoryID + "'}",
                            data: JSON.stringify(RegObj),
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: OnSuccess,
                            failure: function (response) {
                                alert(response.d);
                            },
                            error: function (response) {
                                alert(response.d);
                            }
                        });
                    });
                    function OnSuccess(response) {
                        $("#tblInstallment").DataTable(
                      {
                          bRetrieve: true
                      })
                        $("#tblInstallment").DataTable(
                        {
                            destroy: true,
                            bLengthChange: false,
                            // lengthMenu: [[10, 50, -1], [10, 50, "All"]],
                            bFilter: false,
                            bSort: false,
                            bPaginate: false,
                            // dom: 'Bfrtip',
                            data: response,

                            columns: [
                                //{'data': 'InstallementAmount'},
                                 {
                                     "data": "InstallmentAmount", "name": "InstallmentAmount", "autoWidth": true,
                                     "render": function (data) { return GetInstAmount(data) }
                                 },
                                   {

                                       "data": "DueDate", "name": "DueDate", "autoWidth": true,
                                       "render": function (data) { return GetDueDate(data) }
                                   },
                            ]
                        });
                        function GetDueDate(data) {
                            //  return "<input type='text' class='datepicker' value='" + data + "'/>"
                            return '<input id=\"txtDueDate\" type=\"text\"  class=\"datepicker\"  value="' + data + '">';

                        }
                        function GetInstAmount(data) {
                            if (insttype == "Equal") {
                                return '<input id=\"txtInstallmentAmount\" type=\"textbox\" disabled    value="' + data + '">';
                            }
                            else {
                                return '<input id=\"txtInstallmentAmount\" type=\"textbox\"    value="' + data + '">';
                            }
                        }
                    };

   $(".datepicker").datepicker({
            defaultDate: "dd-M-yy",
            changeMonth: true,
            changeYear: true,
            width: 50,
            dateFormat: "dd-M-yy",
            inline: true
        });


Answers (5)