i am creating columns for the datatable in Jquery.. What will be the datatype of New_Salary field

i am creating columns for the datatable in Jquery.. What will be the datatype of New_Salary field

laxmiparklaxmipark Posts: 22Questions: 8Answers: 0

$('#jquery_table').DataTable(

                {
                    "autoWidth": false,
                    lengthChange: false,
                    data: array,
                     "columns": [
                        { "data": "Assoc_ID", "title": "Associate ID" },
                        { "data": "FullName", "title": "Full Name" },
                        { "data": "Start_Date", "title": "Start Date" },
                        { "data": "Job_Title", "title": "Job Title" },
                        { "data": "Merit_Eligible", "title": "Merit Eligible" },
                        { "data": "Hrly_Assoc", "title": "Hourly Assoc (Y/N)" },
                        { "data": "Compa_Ratio", "title": "Current Compa Ratio" },
                        { "data": "Perf_Rat_Desc", "title": "Performance Rating" },
                        { "data": "Current_Salary", "title": "Current Salary",  render: $.fn.dataTable.render.number(',', '.', 2) },
                        {
                            "data": "Merit_Incr", "title": "Increase %",  render: function (data, type, full, meta) {

                                data = $.trim(data);
                                var rownum = meta.row;
                                var colnum = meta.col;
                                var colName = meta.settings.aoColumns[colnum].data;
                                var disabled = (data != 'NA' ? '' : 'disabled');
                                return '<input ' + disabled + ' class = "form-contorl"  id = "merit_in" onkeypress="return CheckNumeric()" name = "Merit_Incr"  maxlength = "6"  value = ' + data + '>';
                            }

                        },
                        { "data": "New_Salary", "title": "New Salary Rounded", "type": "string", render: $.fn.dataTable.render.number(',', '.', 2) },
                        { "data": "Merit_Amt", "title": "Increase $", render: $.fn.dataTable.render.number(',', '.', 2) },
                        { "data": "New_Compa_Ratio", "title": "New Compa Ratio" },
                        { "data": "Location", "title": "Budget Type" }
                    ],

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Given you've declared it as this:

    ``
    { "data": "New_Salary", "title": "New Salary Rounded", "type": "string", render: $.fn.dataTable.render.number(',', '.', 2) },
    ```

    I would say the type is a string...

  • laxmiparklaxmipark Posts: 22Questions: 8Answers: 0

    Hi Colin,

    Thanks for the reply. As you can see I have input field Merit_incr. when I enter New salary will be updated.. That works fine. the problem is when I press the Save Button I have to save the datatable to SQL database. I am trying to save the datatable via json to C# datatable and then pass it as parameter through the stored procedure. I am getting the error when converting json string to datatable in c# using

    DataTable dt = JsonConvert.DeserializeObject<DataTable>(StrContent);

    the error is as follows
    Input string was not in a correct format.

    Descriptio[ArgumentException: Input string was not in a correct format.
    Couldn't store <77700.00> in New_Salary Column. Expected type is Int64.]n:

    Can you give me the suggestions?

    Thank you

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    Can you add a break point on that line and check what the data type of the New_Salary column is? Can you show me what StrContent contains? I'm wondering if its a string, and you need to convert it to be an integer if your deserialiser isn't doing that for you automatically.

    Allan

  • laxmiparklaxmipark Posts: 22Questions: 8Answers: 0

    its string. So I did convert it into Integer and its working fine. Thanks for your help

This discussion has been closed.