jQWidgets Forums

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts

  • damian_cavs
    Member

    Many thanks Dimitar!!! now I can delete and Update rows!!! never I had entered to “Build CRUD Web App with jqxGrid using PHP and MySQL” because I didn’t understand what is “CRUD”….

    Thanks for your support!!!

    best regards!!!,

    Damian

    in reply to: I can't delete rows… I can't delete rows… #25860

    damian_cavs
    Member

    Sorry:

    data_comercio.php

    $row[‘nombre’],
    ‘categoria’ => $row[‘categoria’],
    ‘precio’ => $row[‘precio’],
    ‘descripcion’ => $row[‘descripcion’]

    );
    }

    $data[] = array(
    ‘TotalRows’ => $total_rows,
    ‘Rows’ => $employees
    );
    echo json_encode($data);
    }
    ?>

    in reply to: I can't delete rows… I can't delete rows… #25859

    damian_cavs
    Member

    con_productos:

    $(document).ready(function () {
    // prepare the data
    var data = {};
    var theme = ‘classic’;
    var source =
    {
    datatype: “json”,
    datafields: [

    { name: ‘nombre’ },
    { name: ‘categoria’},
    { name: ‘precio’ },
    { name: ‘descripcion’ },

    ],
    url: ‘../scripts/data_productos.php’,
    root: ‘Rows’,
    beforeprocessing: function (data) {
    source.totalrecords = data[0].TotalRows;
    },
    updaterow: function (rowid, rowdata, commit) {
    // synchronize with the server – send update command
    var data = “update=true&nombre=” + rowdata.nombre + “&categoria=” + rowdata.categoria + “&precio=” + rowdata.precio;
    data = data + “&descripcion=” + rowdata.descripcion;

    $.ajax({
    dataType: ‘json’,
    url: ‘../scripts/data_productos.php’,
    data: data,
    success: function (data, status, xhr) {
    // update command is executed.
    commit(true);
    },
    error: function () {
    commit(false);
    }
    });
    },
    deleterow: function (rowid, rowdata, commit) {
    // synchronize with the server – send update command
    var data = “delete=true&nombre=” + rowdata.nombre + “&categoria=” + rowdata.categoria + “&precio=” + rowdata.precio;
    data = data + “&descripcion=” + rowdata.descripcion;

    $.ajax({
    dataType: ‘json’,
    url: ‘../scripts/data_productos.php’,
    data: data,
    success: function (data, status, xhr) {
    //delete command is executed.
    commit(true);
    },
    error: function () {
    commit(false);
    }
    });
    }
    };
    var dataadapter = new $.jqx.dataAdapter(source);
    // initialize jqxGrid
    $(“#jqxgrid”).jqxGrid(
    {
    width: 800,
    selectionmode: ‘singlerows’,
    source: dataadapter,
    theme: theme,
    editable: true,
    autoheight: true,
    pageable: true,
    virtualmode: true,

    rendergridrows: function () {
    return dataadapter.records;
    },
    columns: [
    { text: ‘Nombre’, datafield: ‘nombre’, width: 200 },
    { text: ‘Categoria’, datafield: ‘categoria’, width: 200 },
    { text: ‘Precio’, datafield: ‘precio’, width: 200 },
    { text: ‘Descripcion’, datafield: ‘descripcion’, width: 200 }
    ]
    });
    $(“#deletebutton”).jqxButton({ theme: theme });
    // delete row.
    $(“#deletebutton”).on(‘click’, function () {
    var selectedrowindex = $(“#jqxgrid”).jqxGrid(‘getselectedrowindex’);
    var rowscount = $(“#jqxgrid”).jqxGrid(‘getdatainformation’).rowscount;
    if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex);
    var commit = $("#jqxgrid").jqxGrid('deleterow', id);
    }
    });
    });

    data_comercio.php

    $row[‘nombre’],
    ‘categoria’ => $row[‘categoria’],
    ‘precio’ => $row[‘precio’],
    ‘descripcion’ => $row[‘descripcion’]

    );
    }

    $data[] = array(
    ‘TotalRows’ => $total_rows,
    ‘Rows’ => $employees
    );
    echo json_encode($data);
    }
    ?>

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