Definicion de grid con carga local de datos


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $("#obraSocialTable").jqGrid({
  2. datatype: "local",
  3. autowidth: true,
  4. scrollOffset: 0,
  5. shrinkToFit: true,
  6. height: 'auto',
  7. colNames: ['Codigo', 'Descripcion', '', 'Id'],
  8. colModel: [
  9. { name: 'Codigo', width: 15, align: "right", sortable: false },
  10. { name: 'Descripcion', width: 80, align: "left", sortable: false },
  11. { name: 'acciones', width: 5, align: "center", sortable: false },
  12. { name: 'Id', hidden: true }
  13. ],
  14. caption: "Obras Sociales"
  15. });
  16.  
  17. function cargarObrasSociales() {
  18.  
  19. $("#obraSocialTable").jqGrid('clearGridData');
  20.  
  21. var data = obtenerObrasSociales();
  22.  
  23. $.each(data, function (index, value) {
  24. $("#obraSocialTable").jqGrid('addRowData', value.Id, value);
  25. agregarBotonesGrid(value.Id);
  26. });
  27. };
  28.  
  29. function obtenerObrasSociales() {
  30. var obrasSociales;
  31. $.ajax({
  32. type: 'POST',
  33. async: false,
  34. url: '@Url.Action("ObtenerObrasSocialesParaEdicion", "ObraSocial")',
  35. dataType: "json",
  36. contentType: "application/json; charset=utf-8",
  37. success: function (data) {
  38. obrasSociales = data;
  39. },
  40. error: function (jqXhr) {
  41. $("#errorDialog")
  42. .html(jqXhr.responseText)
  43. .dialog('open');
  44. }
  45. });
  46. return obrasSociales;
  47. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.