0

グリッドに日時フィールドを正しく表示するのに苦労しています。年初 ' 2010-05-01 00:00:00 'として表示され、日初 ' 01-05-2010 00:00:00 ' ではありません。mysql では、日時フィールドです。開発者向けドキュメントから入手したさまざまなオプションを試しましたが、何も機能していないようです。私は自分のコードを投稿しました。誰かが私のエラーを強調してくれたら幸いです。ありがとう

jQWidgets v3.2.2 (2014-Mar-21) 開発者サイト

var source =
            {
                datatype: "json",
                datafields: [
                     { name: 'id', type: 'string'},
                     { name: 'date', type: 'date'},
                     { name: 'activity', type: 'string'},
                     { name: 'user', type: 'string'},
                     { name: 'item', type: 'string'}
                ],
                cache: false,
                id: 'id',
                url: 'temp/rtvData.php',           
                updaterow: function (rowid, rowdata, commit) {
                    // synchronize with the server - send update command
                    var data = "update=true&FirstName=" + rowdata.FirstName + "&LastName=" + rowdata.LastName + "&Title=" + rowdata.Title;
                    data = data + "&EmployeeID=" + rowid;

                    $.ajax({
                        dataType: 'json',
                        url: 'temp/rtvData.php',
                        type: 'POST',
                        data: data,
                        success: function (data, status, xhr) {
                            // update command is executed.
                            commit(true);
                        }
                    });     
                }
            };

            var dataAdapter = new $.jqx.dataAdapter(source);

            // initialize the input fields.
            /* $("#activity").jqxInput({width: 150, height: 23});
            $("#user").jqxInput({width: 150, height: 23});
            $("#item").jqxInput({width: 150, height: 23}); */

            var dataAdapter = new $.jqx.dataAdapter(source);
            var editrow = -1;

            // initialize jqxGrid
            $("#jqxgrid").jqxGrid(
            {
                width: 740,
                editable: true,
                sortable: true,
                filterable: true,
                columnsresize: true,
                columnsreorder: true,
                source: dataAdapter,
                pageable: true,
                autoheight: true,
                altrows: true,
                theme: 'custom',
                columns: [
                  { text: 'id', editable: false, datafield: 'id', width: 90 },
                  { text: 'date', editable: false, datafield: 'date', cellsformat: 'D', filtertype: 'date', filterable: true, width: 190},
                  { text: 'Activity', editable: false, datafield: 'activity', width: 100 },
                  { text: 'User', editable: false, datafield: 'user', width: 160 },
                  { text: 'Box', editable: false, datafield: 'item', width: 'auto' },
                  /* { text: 'Edit', datafield: 'Edit', width: 90, sortable: false, filterable: false, columntype: 'button', cellsrenderer: function () {
                     return "Edit";
                     }, buttonclick: function (row) {
                     // open the popup window when the user clicks a button.
                     editrow = row;
                     var offset = $("#jqxgrid").offset();
                     $("#popupWindow").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60 }, theme: 'custom' });

                     // get the clicked row's data and initialize the input fields.
                     var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
                     $("#firstName").val(dataRecord.FirstName);
                     $("#lastName").val(dataRecord.LastName);
                     $("#title").val(dataRecord.Title);

                     // show the popup window.
                     $("#popupWindow").jqxWindow('open');
                 }
                 } */
                ]
            });

rtvData.php

{
    // SELECT COMMAND
    $result = mysql_query($query) or die("SQL Error 1: " . mysql_error());
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $act[] = array(
            'id' => $row['id'],
            'date' => $row['date'],
            'activity' => $row['activity'],
            'user' => $row['user'],
            'item' => $row['item']
          );
    }

    echo json_encode($act);
}
4

1 に答える 1

1

ローカライズのせいかもしれません。このガイドを確認してください:

あなたのコード:

{ text: 'date', editable: false, datafield: 'date', cellsformat: 'D', filtertype: 'date', filterable: true, width: 190},

デフォルトのローカリゼーション メンバー

 patterns: {
// long date pattern
 D: "dddd, MMMM dd, yyyy",
...

http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-localization.htm

良い例え:

http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/localization.htm?web

/編集 2014-08-24

問題にどのようにアプローチするか:

  1. 最初に、SQL クエリが正しい日付形式を返すことを確認します。

    SELECT DATE_FORMAT(datecolumn, %Y.%m.%d) AS NewDate FROM exampletable;

ISO 8601 規格に問題がないので、私はISO 8601 規格を使用するのが好きです。MySQL DATE_FORMATにいくつかの情報があります。

  1. もちろん、次のステップでは、ソース オブジェクトを変更する必要があります。
  2. ここで、参照が設定されていることを確認します。(顧客のローカリゼーション ファイル)

    script type="text/javascript" src="localization.js">

    http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/localization.js

  3. ここで、グリッドのみを調整する必要があります。(ローカライズ属性)

    $("#jqxgrid").jqxGrid( { width: 740, source: dataAdapter, sortable: true, filterable: true, pageable: true, theme: 'custom', localization: getLocalization('de'), columns: [ { text: 'Datefield', datafield: 'date', columntype: 'NewDate', filtertype: 'date', width: 210, cellsalign: 'right', cellsformat: 'd' } ] });

于 2014-08-22T17:08:17.733 に答える