jQWidgets Forums

jQuery UI Widgets Forums Grid Doubling addrow

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  teguh 12 years, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Doubling addrow #13268

    teguh
    Member

    Hi,

    I made popup window editing, i got a problem when i used an ‘addrow’. my grid record add one record at 1st time. But at the 2nd addrow my grid add two record, and also with the next ‘addrow’ (3rd –> 3 record, 4th —> 4 record).
    Please help me,

    Below is my code:

    function _displayGrid(value,level) {
    var source =
    {
    datatype: “json”,
    datafields: [ { name: ‘no’ }, { name: ‘id’}, { name: ‘name’}, { name: ‘description’} ],
    url: ‘remote.cfc?method=getKomplek’,
    data: { categoryLabel: value, categoryLevel: level },
    addrow: function (rowid, rowdata, position, commit) { commit(true); },
    deleterow: function (rowid, commit) { commit(true); },
    updaterow: function (rowid, newdata, commit) { commit(true); }
    };

    var dataAdapter = new $.jqx.dataAdapter(source, { async: false, autoBind: true });
    dataAdapter.dataBind();

    $(“#jqxgrid”).jqxGrid(
    {
    width: ‘100%’,
    height: ‘100%’,
    source: dataAdapter,
    theme: customDemo.config.theme,
    selectionmode: ‘singlerow’,
    sortable: true,
    columnsresize: true,
    pagerheight: 40,
    editable: false,
    showtoolbar: true,
    showstatusbar: true,
    columns: [
    { text: ‘No’, datafield: ‘no’, width: 40, cellsalign: ‘right’ },
    //{ text: ‘ID’, datafield: ‘id’, width: 40, cellsalign: ‘right’ },
    { text: ‘Name’, datafield: ‘name’ },
    { text: ‘Description’, datafield: ‘description’ }
    ],
    rendertoolbar: function (toolbar) {
    var me = this;
    var container = $(“

    “);
    var addSpan = $(““);
    var editSpan = $(““);
    var trashSpan = $(““);
    var tripNumberInput = $(“”);
    toolbar.append(container);
    container.append(addSpan);
    container.append(editSpan);
    container.append(trashSpan);

    var offset = $(“#jqxgrid”).offset();

    addSpan.bind(‘click’,function(){
    var item = $(‘#jqxTree’).jqxTree(‘getSelectedItem’);
    var leveldB = [ “Root”,”Komplek”,”Gedung”,”Lantai”,”Zones”,”Spaces”,”Room” ];
    var row = {};

    $(‘#GraphicsPopupTab’).jqxTabs(‘enableAt’, 2);
    $(‘#GraphicsPopupTab’).jqxTabs(‘enableAt’, 3);
    $(‘#GraphicsPopupTab’).jqxTabs(‘enableAt’, 4);
    $(‘#GraphicsPopupTab’).jqxTabs(‘enableAt’, 5);

    $(“#addName”).val(”);
    $(“#addDescription”).val(”);
    $(“#businessUnitDDlist”).val(”);
    $(“#divisionDDlist”).val(”);
    $(“#departmentDDlist”).val(”);
    $(“#addCountrydropdownlist”).val(”);
    $(“#addProvincedropdownlist”).val(”);
    $(“#addCitydropdownlist”).val(”);
    $(“#addDistrictdropdownlist”).val(”);

    $(“#createWindow”).jqxWindow({
    position: { x: parseInt(offset.left) + 10, y: parseInt(offset.top) + 10},
    title: ‘Tambah Record ‘ + leveldB[item.level+1] + ‘ untuk ‘ + leveldB[item.level] + ‘ : ‘ + item.label,
    width: 800,
    theme: customDemo.config.theme,
    isModal: true,
    modalOpacity: 0.01,
    autoOpen: false,
    okButton: $(‘#PSave’),
    cancelButton: $(‘#PCancel’)
    });

    $(“#createWindow”).jqxWindow(‘open’);

    $(“#PSave”).bind(‘click’, function(){
    var item = $(‘#jqxTree’).jqxTree(‘getSelectedItem’);
    var leveldB = [ “Root”,”Komplek”,”Gedung”,”Lantai”,”Zones”,”Spaces”,”Room” ];
    var rowscount = $(“#jqxgrid”).jqxGrid(‘getdatainformation’).rowscount;
    var row = {};
    row[“table”] = leveldB[item.level+1];
    row[“tabel_record”] = item.label;
    row[“no”] = rowscount + 1;
    row[“name”] = $(“#addName”).val();
    row[“description”] = $(“#addDescription”).val();
    row[“business_unit”] = $(“#businessUnitDDlist”).val();
    row[“division”] = $(“#divisionDDlist”).val();
    row[“department”] = $(“#departmentDDlist”).val();
    row[“account”] = $(“#addAccount”).val();
    row[“country”] = $(“#addCountrydropdownlist”).val();
    row[“province”] = $(“#addProvincedropdownlist”).val();
    row[“city”] = $(“#addCitydropdownlist”).val();
    row[“district”] = $(“#addDistrictdropdownlist”).val();
    row[“village”] = $(“#addVillage”).val();
    row[“office_area”] = $(“#officeArea”).val();
    row[“warehouse”] = $(“#warehouseArea”).val();
    row[“production”] = $(“#productionArea”).val();
    var commit = $(“#jqxgrid”).jqxGrid(‘addrow’, null, row);
    $(“#createWindow”).jqxWindow(‘close’);
    });

    });

    editSpan.bind(‘click’,function() {

    $(‘#GraphicsPopupTab’).jqxTabs(‘enableAt’, 2);
    $(‘#GraphicsPopupTab’).jqxTabs(‘enableAt’, 3);
    $(‘#GraphicsPopupTab’).jqxTabs(‘enableAt’, 4);
    $(‘#GraphicsPopupTab’).jqxTabs(‘enableAt’, 5);

    var selectedrowindex = $(“#jqxgrid”).jqxGrid(‘getselectedrowindex’);
    if (selectedrowindex == -1) {
    alert(‘Pilih record terlebih dahulu!’);
    }
    var rowscount = $(“#jqxgrid”).jqxGrid(‘getdatainformation’).rowscount;
    if (selectedrowindex >= 0 && selectedrowindex = 0 && selectedrowindex = 0 && selectedrowindex < rowscount) {
    var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex);
    var commit = $("#jqxgrid").jqxGrid('deleterow', id);
    }
    });
    }
    });
    };

    Create

    Detail
    Alamat
    Area
    Pembayaran
    Dokumen
    Notes

     

    Nama :

    Deskripsi :

    Suku Usaha :

    Divisi :

    Departemen :

    Nomor Perkiraan :

    <!—
    —>

    <!—

    —>
     

    Negara :

    Provinsi :

    Kota/Kabupaten :

    Kecamatan :

    Desa :

     

    Luas Area Kantor :

    Area Gudang :

    Luas Area Produksi :

    Edit

    Detail
    Alamat
    Area
    Pembayaran
    Dokumen
    Notes

     

    Nama :

    Deskripsi :

    Suku Usaha :

    Divisi :

    Departemen :

    Nomor Perkiraan :

    <!—
    —>

    <!—

    —>
     

    Negara :

    Provinsi :

    Kota/Kabupaten :

    Kecamatan :

    Desa :

     

    Luas Area Kantor :

    Area Gudang :

    Luas Area Produksi :

    Doubling addrow #13270

    Peter Stoev
    Keymaster

    Hi teguh,

    The rendertoolbar callback is called when the Grid is rendered. The ‘addrow’ causes re-render so the callback is called again. Inside that function you create and bind to events. I suggest you to create the jqxWindow outside the rendertoolback callback.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Doubling addrow #13334

    teguh
    Member

    I moved
    $(“#PSave”).bind(‘click’, function(){ * } ;
    to the outside
    $(“#jqxgrid”).jqxGrid({ * });
    and the problem solved.

    thank’s peter

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

You must be logged in to reply to this topic.