Guest User

Untitled

a guest
Oct 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. var objTipo = new Object();
  2. objTipo.id = $('#ddlTipoAuditoria').val();
  3. var datatable = $('#tableItemsAuditorias').DataTable({
  4. ajax: {
  5. method: "POST",
  6. url: 'Auditoria.aspx/GetSubItemsAuditorias',
  7. //url: 'Auditoria.aspx/GetItemsAuditorias',
  8. contentType: "application/json; charset=utf-8",
  9. dataType: "json",
  10. data: function (d) { return JSON.stringify(objTipo); },
  11. dataSrc: "d.data"
  12. },
  13. "columns": [
  14. { "data": "idItem", "autoWidth": true, "visible": false },
  15. { "data": "nombreItem", "autoWidth": true },
  16. { "data": "idSubItem", "autoWidth": true, "visible": false },
  17. { "data": "nombre", "autoWidth": true },
  18. { "data": "idUM", "autoWidth": true, "visible": false },
  19. {
  20. "render": function (d, t, r, meta) {
  21. var $select = $("<select class='tipo-unidad'></select>", {
  22. "id": r[0] + "start",
  23. "value": d
  24. });
  25. var modelo = models.data;
  26. $.each(modelo, function (k, v) {
  27. if (v.idUM == r.idUM)
  28. {
  29. // Pregunta si el r.idUM (la unidad de medida que tiene el item es igual
  30. // al tipo de uM cargado en el combo. Si es si lo muestra)
  31. var $option = $("<option></option>", {
  32. "text": v.nombre,
  33. "value": v.idTipoUnidad
  34.  
  35. });
  36.  
  37. if (d == v) {
  38. $option.attr("selected", "selected")
  39. //$option = $("<option selected></option>", {
  40. // "text": v.nombre,
  41. // "value": v.idTipoUnidad
  42. //});
  43.  
  44. }
  45. $select.append($option);
  46. }
  47. });
  48. return $select.prop("outerHTML");
  49. }
  50. }
  51.  
  52. var table = $('#tableItemsAuditorias').DataTable();
  53. var data = table.rows().data();
  54. //idTipoUM
  55. var x = table.rows();
  56. data.each(function (value, index) {
  57. alert('Data in index: ' + index + ' is: ' + value.nombre);
  58. alert('valor: ' + $('.tipo-unidad').val()); //siempre muestra el mismo valor, el del primer select
  59.  
  60. });
Add Comment
Please, Sign In to add comment