jQuery UI Widgets Forums Grid Empty grid after addrow

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

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • Empty grid after addrow #58528

    eabarca
    Participant

    Hi, i have this url for grid source: url:

    includes/funciones.php?funcion=get_pacientes_contactos&IdPaciente=' + $('#IdPaciente').val()

    and when i set a value to IdPaciente input and then addrow grid doesnt show anything, but record is created. Now, if i set IdPaciente by parameter i got all records i need.
    I think grid doesnt take this kind of changes on url source. Any help? Thanks.-

    Empty grid after addrow #58530

    Dimitar
    Participant

    Hello eabarca,

    Did you call the grid’s updatebounddata method? See also the forum topic the grid add blank row when the virtual mode is enabled for a possibly similar scenario.

    Best Regards,
    Dimitar

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

    Empty grid after addrow #58598

    eabarca
    Participant

    Yes, i use updatebouddata after addrow, update and delete, but im not using virtualmode. I think this is cause url: IdPaciente is empty, but when i set a value grids adapter doesnt know url has changed. Maybe if i created source again when IdPaciente is set, grid must show records vinculated with this IdPaciente, its possible?

    url: 'includes/funciones.php?funcion=get_pacientes_domicilios&IdPaciente=' + $('#IdPaciente').val(),
    addrow: function (rowid, rowdata, position, commit) {
    		var data = 'op=AltaDomicilios&' + $.param(rowdata);
    		$.ajax({
    			datatype: 'json',
    			type: 'POST',
    			url: 'post.php',
    			data: data,
    			cache: false,
    			success: function (data, status, xhr) {
    				commit(true, data);
    				$('#jqxgridDomicilios').jqxGrid('updatebounddata');
    			},
    			error: function (jqXHR, textStatus, errorThrown) {
    				commit(false);
    			}
    		});
    	},
    deleterow: function (rowid, commit) {
    		var data = 'op=BajaDomicilios&' + $.param(rowid);
    		$.ajax({
    			datatype: 'json',
    			type: 'POST',
    			url: 'post.php',
    			data: data,
    			cache: false,
    			success: function (result) {
    				commit(true);
    				$('#jqxgridDomicilios').jqxGrid('updatebounddata');
    			},
    			error: function(result){
    				commit(false);
    			}
    		});
    	},
    updaterow: function(rowid, newdata, commit){
    		var data = 'op=ModificacionDomicilios&' + $.param(newdata);
    		$.ajax({
    			datatype: 'json',
    			type: 'POST',
    			url: 'post.php',
    			data: data,
    			cache: false,
    			success: function (result) {
    				commit(true);
    				$('#jqxgridDomicilios').jqxGrid('updatebounddata');
    			},
    			error: function(result){
    				commit(false);
    			}
    		});
    	}
    Empty grid after addrow #58600

    Dimitar
    Participant

    Hi eabarca,

    Please try calling updatebounddata each time the value of the IdPaciente input changes (e.g. in its change event).

    Best Regards,
    Dimitar

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

    Empty grid after addrow #58686

    eabarca
    Participant

    Thanks for the reply, but unfortunately it doesnt work. I created a button:

    $("#refresh").on('click', function(){
    	$('#jqxgridDomicilios').jqxGrid('updatebounddata');
    });

    but dont matter what IdPaciente value is, grid doesnt show added rows.

    Empty grid after addrow #58700

    eabarca
    Participant

    I solved my problem redirecting php file with IdPaciente parameter after i set a value to this:

    Original php: http://localhost/pacientes/carga_paciente.php
    Redirected php: http://localhost/pacientes/carga_paciente.php?IdPaciente=2014003310 (e.g.)

    That way grid returns all values refered to this IdPaciente parameter. Is not the best solution, but now it works as i need.
    It seems url from adapter doesnt get refresh after calling updateboundata

    Empty grid after addrow #58712

    Dimitar
    Participant

    Hi eabarca,

    You need to manually set the url before calling updatebounddata:

    $("#refresh").on('click', function() {
        source.url = 'includes/funciones.php?funcion=get_pacientes_domicilios&IdPaciente=' + $('#IdPaciente').val();
        $('#jqxgridDomicilios').jqxGrid('updatebounddata');
    });

    Best Regards,
    Dimitar

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

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

You must be logged in to reply to this topic.