Advertisement
loonerz

function for filling list view

Jan 29th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function swapDiv(e) {
  2.     selection = e.value;
  3.     var url = '';
  4.     var model = {};
  5.     switch (selection) {
  6.         case 'Usuarios':
  7.             url = "http://127.0.0.1:81/SismosService.svc/usuario/index";
  8.             template = '#usuariosTemplate';
  9.             model = {
  10.                 id: "Nombre",
  11.                 fields: {
  12.                     Nombre: { type: "string" },
  13.                     ApellidoP: { type: "string" },
  14.                     ApellidoM: { type: "string" },
  15.                 }
  16.             };
  17.             break;
  18.         case 'Regiones':
  19.             url = "http://127.0.0.1:81/SismosService.svc/region/index";
  20.             template = '#regionesTemplate';
  21.             model = {
  22.                 id: "Nombre",
  23.                 fields: {
  24.                     Nombre: { type: "string" }
  25.                 }
  26.             };
  27.             break;
  28.         case 'Clusters':
  29.             url = "http://127.0.0.1:81/SismosService.svc/cluster/index";
  30.             template = '#clustersTemplate';
  31.             model = {
  32.                 id: "Nombre",
  33.                 fields: {
  34.                     Nombre: { type: "string" }
  35.                 }
  36.             };
  37.             break;
  38.         case 'Dispositivos':
  39.             url = "http://127.0.0.1:81/SismosService.svc/dispositivo/index";
  40.             template = '#dispositivosTemplate';
  41.             model = {
  42.                 id: "Alias",
  43.                 fields: {
  44.                     Alias: { type: "string" }
  45.                 }
  46.             };
  47.             break;
  48.         case 'Eventos':
  49.             url = "http://127.0.0.1:81/SismosService.svc/evento/index";
  50.             template = '#eventosTemplate';
  51.             break;
  52.     }
  53.     $.ajax({
  54.         url: url,
  55.         success: function (data) {
  56.             var src = null;
  57.             if (template == '#eventosTemplate')
  58.             {
  59.                 src = getEventosArray(data);
  60.             }
  61.             else
  62.             {
  63.                 src = data.Response;
  64.             }
  65.             var ds = new kendo.data.DataSource({
  66.                 data: src,
  67.                 schema: {
  68.                     model: model
  69.                 }
  70.             });
  71.             $('#listView').kendoListView({
  72.                 dataSource: ds,
  73.                 template: kendo.template($(template).html())
  74.             });
  75.         },
  76.         error: function (data) {
  77.             console.log('Error: ' + JSON.stringify(data));
  78.         }
  79.     });
  80.     $('#selectionBar').animate({
  81.         left : '189'
  82.     }, 500);
  83.     $('#dataBar').animate({
  84.         left: '0'
  85.     }, 500);
  86.     $('#myMap').animate({
  87.         left : '370'
  88.     }, 500);
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement