updateFromXML

hello,



have a question regarding your updateFromXML method for grid/treegrid dhtmlx objects.



1) Is it possible to have newly added rows at the top of the grid instead of at the bottom?



2) what are the conditions that decide whether a row has changed? if userdata changes or background/styling of row changes, the updateFromXML doesnot consider this row to be updated…is this normal behaviour?



3) if values are no longer present in the new retrieved XML, the corresponding rows are NOT deleted from the grid…is this expected behavior?





Just wondering if there was any easy way to get any of the above to work properly? Else, i guess i’ll stick with the classic clear/load.





Thanks,

  1. Is it possible to have newly added rows at the top of the grid instead of at the bottom?
    Only by code modification
    dhtmlxgrid.js , line 4733
    this.rowsBuffer.push({ //need to be changed to add to first position
    line 4746
    this._insertRowAt(row,-1) //second parameter need to be changed to 0

    >>2) what are the conditions that decide whether a row has changed?
    Actually grid updates data for all rows which exist in grid, but it not revert back any additional settings ( such as styles and userdata )
    The main usage for updateFromXML - updating rows data, it may be not reliable for updating styles.

    >>3) if values are no longer present in the new retrieved XML
    grid compare new and old XML by row IDs , so if there is no row with some ID in XML, but it exists in grid - such row will be deleted ( only if 3rd parameter of updateFromXML set to true )

    >>Just wondering if there was any easy way to get any of the above to work properly?
    (3) must work correctly if correct IDs | parameters provided
    (2) works correctly for cell values and new attributes, but not clear old attributes
    (1) can’t be easily changed

Hello :slight_smile:

Is the question 1 planed to be solved by a parameter in a future version ?

Thanks for your answer :slight_smile:

Oncoming release will not have any modification related to updateFromXML feature.
In long run - we have plans to replace updateFromXML to datasource agnostic method ( which will be able to do the same functionality but with all data types xml, csv, json ) , probably ability to configure, how new rows added - will be added as well.

I changed dhtmlxgrid.js _insertRowAt function to be able add new rows to the top of grid by modifying next code

		if (!skip)
			if ((ind == (this.obj.rows.length-1))||(!this.rowsCol[ind]))
				if (_isKHTML)
					this.obj.appendChild(r);
				else {
					else this.obj.firstChild.appendChild(r);
					
				}
			else {
				this.rowsCol[ind].parentNode.insertBefore(r, this.rowsCol[ind]);
			}

on

[code]
if (!skip)
if ((ind == (this.obj.rows.length-1))||(!this.rowsCol[ind]))
if (_isKHTML)
this.obj.appendChild®;
else {
if (GLOBAL_VAR == 1) this.obj.insertBefore(r, this.obj.firstChild);
else this.obj.firstChild.appendChild®;

			}
		else {
			this.rowsCol[ind].parentNode.insertBefore(r, this.rowsCol[ind]);
		}[/code]

But after inserting new row in my grid style was changed:
header remain the saim, but other rows changed its width.
I was checked in firebug and there is no changes in attributes of grid like cellWidthPX or another linked with width.
How to fix this?

If you are using pro version of dhtmlxgrid - please open ticket in support system, we can provide a version of dhtmlxgrid pro, which has an option to add new rows to the top, during updating from xml.

Stanislav,
I don’t have pro version.
May be i didn’t right. I load grid from xml and update grid from temp grid that refreshing. New rows in temp grid (it is invisble) i add to grid by modifying addRow function.
I can’t understand where width of column was updated and what is the reason of this behavior.

As far as I can see you are adding row to the incorrect place.

First row in table object is invisible line which controls width of columns. So when adding row to top of grid, you need to add them after that sizing row, not as first row.