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.
-
AuthorEmpty grid after addrow Posts
-
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.-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,
DimitarjQWidgets team
http://www.jqwidgets.com/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); } }); }
Hi eabarca,
Please try calling updatebounddata each time the value of the IdPaciente input changes (e.g. in its change event).
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/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.
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 updateboundataHi 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,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.