jQuery UI Widgets Forums Grid add row – row not available

This topic contains 3 replies, has 3 voices, and was last updated by  Dimitar 10 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • add row – row not available #59220

    aldo86
    Participant

    Hi,
    I’ve implemented addrow and it works but if i try to do something on that row I retrieve an error that the row is undefined. So it seems that the localdata is not updated in that moment. This is my code:

    
    //data source
    _this.source =
            {
                localdata: data,
                totalrecords: 200000,
                datafields: datafields,
                datatype: "json",
                addrow: function (rowid, rowdata, position, commit) {
                    // synchronize with the server - send insert command
                    // call commit with parameter true if the synchronization with the server is successful 
                    //and with parameter false if the synchronization failed.
                    // you can pass additional argument to the commit callback which represents the new ID if it is generated from a DB.
                    commit(true);
                },
                deleterow: function (rowid, commit) {
                    // synchronize with the server - send delete command
                    // call commit with parameter true if the synchronization with the server is successful 
                    //and with parameter false if the synchronization failed.
                    commit(true);
                },
                updaterow: function (rowid, newdata, commit) {
                    // synchronize with the server - send update command
                    // call commit with parameter true if the synchronization with the server is successful 
                    // and with parameter false if the synchronization failed.
                    commit(true);
                }
            };
            _this.dataAdapter = new $.jqx.dataAdapter(_this.source);
    
    //init grid
    $("#jqxgrid").jqxGrid({
            	theme: _this.theme,
                width: '100%',
                height: '100%',
                source: _this.dataAdapter,
                editable: true,
                altrows: true,
                selectionmode: 'multiplecellsadvanced',
                columnsresize: true,
                editmode: 'click',
                cellhover: function (element, pageX, pageY)
                {
                	
                	if($(element.innerHTML).attr("data-title")){
    	                // update tooltip.
    	                $(element).jqxTooltip({ content: $(element.innerHTML).attr("data-title"), width: 400 });
    	                // open tooltip.
    	                $(element).jqxTooltip('open', pageX + 15, pageY + 15);
                	}else{
                		$(".jqx-grid-cell").jqxTooltip('close');
                	}
                },
                columns: columnsH...
    
    //add row
    var commit = $("#jqxgrid").jqxGrid('addrow', null, {}, rowindex);
    

    Best Regards

    add row – row not available #59233

    Nadezhda
    Participant

    Hello aldo86,

    The last parameter of the “addrow” method is optional. You can use values like: “first” and “last”. Also you can add a new row as the first or last row in jqxGrid and you can not pass row index (number).

    Best Regards,
    Nadezhda

    jQWidgets team
    http://www.jqwidgets.com/

    add row – row not available #59234

    aldo86
    Participant

    Hi Nadezhda,
    I do this because i need to add row above a selected cell and it works! The row is added perfectly without any error. My problem is that this row is not added to localdata, the adapter is not refreshed.
    For example when I add an empty col in localdata like this:

    while(j<rowscounts){
        		if(_this.source.localdata[j])
        			_this.source.localdata[j].push('');
        		j++;
    }

    and var j has the val of the rowindex I get an error that element is undefined.

    So what can I do to update it?

    Best Regards
    Aldo

    add row – row not available #59293

    Dimitar
    Participant

    Hello Aldo,

    Note that this feature may work but it is not documented and thus not supported.

    As for updating the data adapter – the grid binds to the data one-way. You can implement server synchronisation in the addrow, deleterow and updaterow source callback functions (example). Two-way binding is also available if you integrate the grid with Knockout.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.