jQWidgets Forums

jQuery UI Widgets Forums Grid Add new row with today date

This topic contains 4 replies, has 2 voices, and was last updated by  reggaeone13 11 years, 9 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • Add new row with today date #28611

    reggaeone13
    Participant

    I am using the jqxGrid and I want to add a new row with today date (culture de-DE) by default.

    Is this possible?

    Please, help.

    Add new row with today date #28661

    Peter Stoev
    Keymaster

    Hi reggaeone13,

    For adding rows, please look at: createremoveupdatedata.htm.

    The sample shows how to add new rows to a Grid. The row is an Object with Key/Value pairs. The key is the column’s datafield, the Value is the cell’s value. To set Today as cell value, you should it to new Date();

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Add new row with today date #28678

    reggaeone13
    Participant

    Thanks a lot for the rapid answer. This is great!!!.

    I already use the documentation.
    The example in the documentation works with local array and the new row is complete at the beginning.
    That is the difference.

    My problem is: by adding the row the updaterow method is called:

    -> var commit = $(“#jqxgrid”).jqxGrid(‘updaterow’, rowindex, rowData);

    and an empty row will be showed, because the incomplete added row cannot be save into the SQL database (because of constrains).
    In source object I have no addrow method, only updaterow.

    Should I add a addrow in source object?

    Here is my code:

    // today value to show by creating of a new row
    var today = new Date();
    var formattedCurDate = “”;

    if ($.jqx.dataFormat.isDate(today)) {
    // german date
    formattedCurDate = $.jqx.dataFormat.formatdate(today, ‘dd.MM.yyyy’);
    }

    var generaterow = function () {
    var row = {};
    row[“Id”] = createGuid(); // Id column is set to be invisible
    row[“Date”] = new Date(); // this does not work -> formattedCurDate;

    return row;
    };

    addButton.bind(‘click’, function () {
    var rowIndex = $(“#jqxgrid”).jqxGrid(‘getdatainformation’).rowscount;
    var generatedRow = generaterow();

    $(‘#jqxgrid’).jqxGrid(‘addrow’, null, generatedRow);

    // jqxGrid doesn’t scroll to the page, so do it ourselves
    var value = $(‘#jqxgrid’).jqxGrid(‘getrows’).length;
    $(‘#jqxgrid’).jqxGrid(‘ensurerowvisible’, value);
    });

    { text: ‘Datum’, dataField: ‘Date’, columntype: ‘datetimeinput’, cellsalign: ‘left’, cellsformat: ‘d’, width: ‘8%’,
    validation: function (cell, value) {

    },

    cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
    if (newvalue > curDate) {
    return curDate;
    }
    if (newvalue == “”) {
    return oldvalue;
    }
    }

    },

    Many thanks in advance.

    Add new row with today date #28685

    Peter Stoev
    Keymaster

    Hi reggaeone13,

    The “addrow” callback of the source object is called when the Grid’s “addrow” method is called. It is appropriate for synchronization with the server when a new row is added. To add an empty row, you can do that: $(“#grid”).jqxGrid(‘addrow’, null, {}); “updaterow” is called whenever a row is updated or a cell value from a row is updated.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Add new row with today date #28698

    reggaeone13
    Participant

    Hi,

    many thanks for the answer.

    I read many Topics in this Forum before I decide to write here.
    I read the documentation many times and I followed the example “jqxGrid CRUD (ASP .NET MVC3)” step by step.
    This example “jqxGrid CRUD (ASP .NET MVC3)” cannot synchronize with my SQL Server on my system. No “updaterow” in database, no “addrow” in database, no “deleterow” in database.
    All this operations are generated in this example by clicking on the buttons, right to the grid and this is possible, because the data in this example comes from local Array. A “addrow” operation adds a complete row per random.

    But, the synchronization with my SQL Server does not work neither in this example nor simple ASP.NET (I use ASP.NET and the grid can be bound and data from SQL Server can be displayed into the grid, but this is the only thing that it works!!!).

    I cannot synchronize the data with the SQL Server.
    I followed all what you said, but no “addrow” and no “updaterow” can be done in the database.

    Please, tell me, what should I do?
    Or better, please, can someone help, that has success with the CRUD Operation using SQL Sever?

    Please, please help!
    I spend many hours and days with this.
    I don’t know, what next!!

    Thank you very, very much!

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

You must be logged in to reply to this topic.