jQWidgets Forums

jQuery UI Widgets Forums Grid Virtual Pagination problem

This topic contains 0 replies, has 1 voice, and was last updated by  wormie007 11 years, 1 month ago.

Viewing 1 post (of 1 total)
  • Author
  • Virtual Pagination problem #54426

    wormie007
    Participant

    Hi. I have a grid with virtual pagination with aspx. Apart of the initial source, it have three buttons that change the source.

    Data apears correctly, but if i charge a source with 30 records it oviously make three pages, but then if I change to a source with 0 records, it apears that the grid haven’t data to show, this is ok, but it keeps the last totalrecords and pagination where some record was.

    here is the code I use:

    function cellrender(row, column, value, columnproperties, property, datafield) {

    //Soluciona el bug de jquery al agrupar que muestra un index distinto al que ha de usarse
    if ($(“#jqxgrid”).jqxGrid(‘getrootgroupscount’) > 0) {
    var cRows = $(“#jqxgrid”).jqxGrid(‘getrows’).length;
    if (row >= cRows)
    row -= cRows;
    }

    value = $(‘#jqxgrid’).jqxGrid(‘getcelltext’, row, column);

    if (value != null) {

    //lamar funcion y guardar valor nuevo
    var datas = ‘{Codigo:”‘ + value + ‘”}’;

    $.ajax({
    type: “POST”,
    cache: false,
    async: false,
    url: ‘Paginas/Metodos.aspx/ObtenerMedicoMedular’,
    data: datas,
    datatype: “json”,
    contentType: “application/json; charset=utf-8”,
    success: function (data, status, xhr) {
    value = data.d;
    },
    error: function (xhr, ajaxOptions) {
    InsertarError(“AJAX”, “Error Medico Medular”);
    }
    });
    return value;
    }
    }

    var imagerenderer = function (row, datafield, value) {
    if (value !== “”) {
    var imagen = value.replace(” “, “”);
    return ‘' + value + '‘;
    }
    }

    var source =
    {
    datatype: “xml”,
    datafields: [
    { name: ‘Historia’, type: ‘string’ },
    { name: ‘Nombre’, type: ‘string’ },
    { name: ‘Apellido1’, type: ‘string’ },
    { name: ‘Apellido2’, type: ‘string’ },
    { name: ‘Cic’, type: ‘string’ },
    { name: ‘Fecha_Prescripcion’, type: ‘string’ },
    { name: ‘Procedencia’, type: ‘string’ },
    { name: ‘Tipo_Tratamiento’, type: ‘string’ },
    { name: ‘Turno’, type: ‘string’ },
    { name: ‘Medico_Medulares’, type: ‘int’ },
    { name: ‘Fecha_Alta’, type: ‘string’ },

    { name: ‘Fisioterapeuta’, type: ‘int’ },
    { name: ‘Transporte’, type: ‘boolean’ },
    { name: ‘Fecha_Inicio’, type: ‘string’ },
    { name: ‘Fecha_Revision’, type: ‘string’ },
    { name: ‘Sesion’, type: ‘string’ },
    { name: ‘L’, type: ‘boolean’ },
    { name: ‘M’, type: ‘boolean’ },
    { name: ‘X’, type: ‘boolean’ },
    { name: ‘J’, type: ‘boolean’ },
    { name: ‘V’, type: ‘boolean’ },
    { name: ‘S’, type: ‘boolean’ },
    { name: ‘D’, type: ‘boolean’ },
    { name: ‘medicoNombre’, type: ‘string’ },
    { name: ‘medicoApellido1’, type: ‘string’ },
    { name: ‘medicoApellido2’, type: ‘string’ },
    { name: ‘Estado’, type: ‘string’ },
    { name: ‘Solicitante’, type: ‘string’ },
    { name: ‘Observaciones’, type: ‘string’ }
    ],
    formatdata: function (data) {
    //Envio de la pagina y el tamaño necesarios para la funcion y asi ahorrar velocidad de ejecucion del Script
    return { pagenum: data.pagenum, pagesize: data.pagesize }
    },
    record: ‘Table’,
    url: ‘Paginas/Metodos.aspx/GetTratamientos’
    };

    var dataAdapter = new $.jqx.dataAdapter(source, { contentType: ‘application/json; charset=utf-8’,
    loadError: function (jqXHR, status, error) {
    alert(error);
    },
    downloadComplete: function () {
    // update the totalrecords count.
    $.ajax({
    url: ‘Paginas/Metodos.aspx/GetTotalRowsCount’,
    contentType: ‘application/json; charset=utf-8’,
    async: false,
    success: function (data) {
    source.totalrecords = (data.d);
    }
    });
    }
    });

    $(“#jqxgrid”).jqxGrid(
    {
    source: dataAdapter,
    theme: ‘energyblue’,
    width: ‘90%’,
    editable: false,
    showstatusbar: true,
    statusbarheight: 75,
    showtoolbar: true,
    sortable: true,
    pageable: true,
    filterable: true,

    virtualmode: true,
    rendergridrows: function (args) {
    return args.data;
    },

    autoheight: true,
    autorowheight: false,
    columnsreorder: true,
    autoshowfiltericon: false,
    groupable: true,
    localization: getLocalization(),
    columnsresize: true,
    rendertoolbar: function (toolbar) {
    var container = $(“<div style=’text-align:center;’></div>”);
    var title = $(“<label class=’label’>Supervisión de Rehabilitación</label>”);
    container.append(title);
    toolbar.append(container);
    },
    renderstatusbar: function (statusbar) {
    var container = $(“<div style=’overflow: hidden; position: relative; margin: 5px;’></div>”);
    var AltasSinRevisar = $(“<div style=’float: left; margin-left: 5px;’><span style=’margin-left: 4px; margin-bottom: 4px; position: relative;’>Altas sin Revisar</span></div>”);
    var VerTodos = $(“<div style=’float: left; margin-left: 5px;’><span style=’margin-left: 4px; margin-bottom: 4px; position: relative;’>Ver Todos</span></div>”);
    var SolicitudesDeCita = $(“<div style=’float: left; margin-left: 5px;’><span style=’margin-left: 4px; margin-bottom: 4px; position: relative;’>Ver Solicitudes de Cita</span></div>”);

    container.append(AltasSinRevisar);
    container.append(VerTodos);
    container.append(SolicitudesDeCita);

    $.ajax({
    cache: false,
    url: ‘Paginas/Metodos.aspx/mensajesNuevos’,
    datatype: “json”,
    contentType: “application/json; charset=utf-8”,
    success: function (data, status, xhr) {
    if (data.text == “true”) {
    container.append(MensajesNuevos);
    }
    },
    error: function (xhr, ajaxOptions) {
    InsertarError(“AJAX”, xhr.responseText);
    }
    });

    statusbar.append(container);

    AltasSinRevisar.jqxButton({ height: 20, theme: ‘energyblue’ });
    VerTodos.jqxButton({ height: 20, theme: ‘energyblue’ });
    SolicitudesDeCita.jqxButton({ height: 20, theme: ‘energyblue’ });

    VerTodos.click(function (event) {
    //Se muestran todos los registros de la tabla T_Tratamiento_Medular
    source =
    {
    datatype: “xml”,
    datafields: [
    { name: ‘Historia’, type: ‘string’ },
    { name: ‘Nombre’, type: ‘string’ },
    { name: ‘Apellido1’, type: ‘string’ },
    { name: ‘Apellido2’, type: ‘string’ },
    { name: ‘Cic’, type: ‘string’ },
    { name: ‘Fecha_Prescripcion’, type: ‘string’ },
    { name: ‘Procedencia’, type: ‘string’ },
    { name: ‘Tipo_Tratamiento’, type: ‘string’ },
    { name: ‘Turno’, type: ‘string’ },
    { name: ‘Medico_Medulares’, type: ‘int’ },
    { name: ‘Fecha_Alta’, type: ‘string’ },

    { name: ‘Fisioterapeuta’, type: ‘int’ },
    { name: ‘Transporte’, type: ‘boolean’ },
    { name: ‘Fecha_Inicio’, type: ‘string’ },
    { name: ‘Fecha_Revision’, type: ‘string’ },
    { name: ‘Sesion’, type: ‘string’ },
    { name: ‘L’, type: ‘boolean’ },
    { name: ‘M’, type: ‘boolean’ },
    { name: ‘X’, type: ‘boolean’ },
    { name: ‘J’, type: ‘boolean’ },
    { name: ‘V’, type: ‘boolean’ },
    { name: ‘S’, type: ‘boolean’ },
    { name: ‘D’, type: ‘boolean’ },
    { name: ‘medicoNombre’, type: ‘string’ },
    { name: ‘medicoApellido1’, type: ‘string’ },
    { name: ‘medicoApellido2’, type: ‘string’ },
    { name: ‘Estado’, type: ‘string’ },
    { name: ‘Solicitante’, type: ‘string’ },
    { name: ‘Observaciones’, type: ‘string’ }
    ],
    formatdata: function (data) {
    //Envio de la pagina y el tamaño necesarios para la funcion y asi ahorrar velocidad de ejecucion del Script
    return { pagenum: data.pagenum, pagesize: data.pagesize }
    },
    record: ‘Table’,
    url: ‘Paginas/Metodos.aspx/GetTodosTratamientos’
    };

    dataAdapter = new $.jqx.dataAdapter(source, { contentType: ‘application/json; charset=utf-8’,
    loadError: function (jqXHR, status, error) {
    alert(error);
    },
    downloadComplete: function () {
    // update the totalrecords count.
    $.ajax({
    url: ‘Paginas/Metodos.aspx/GetTodosTratamientosRowsCount’,
    contentType: ‘application/json; charset=utf-8’,
    async: false,
    success: function (data) {
    source.totalrecords = (data.d);
    }
    });
    }
    });

    $(“#jqxgrid”).jqxGrid({ source: dataAdapter });
    $(‘#jqxgrid’).jqxGrid({ selectedrowindex: -1 });
    });

    AltasSinRevisar.click(function (event) {

    //Se muestran los registros de la tabla T_Tratamiento_Medular que estan sin revisar y dados de alta
    source =
    {
    datatype: “xml”,
    datafields: [
    { name: ‘Historia’, type: ‘string’ },
    { name: ‘Nombre’, type: ‘string’ },
    { name: ‘Apellido1’, type: ‘string’ },
    { name: ‘Apellido2’, type: ‘string’ },
    { name: ‘Cic’, type: ‘string’ },
    { name: ‘Fecha_Prescripcion’, type: ‘string’ },
    { name: ‘Procedencia’, type: ‘string’ },
    { name: ‘Tipo_Tratamiento’, type: ‘string’ },
    { name: ‘Turno’, type: ‘string’ },
    { name: ‘Medico_Medulares’, type: ‘int’ },
    { name: ‘Fecha_Alta’, type: ‘string’ },

    { name: ‘Fisioterapeuta’, type: ‘int’ },
    { name: ‘Transporte’, type: ‘boolean’ },
    { name: ‘Fecha_Inicio’, type: ‘string’ },
    { name: ‘Fecha_Revision’, type: ‘string’ },
    { name: ‘Sesion’, type: ‘string’ },
    { name: ‘L’, type: ‘boolean’ },
    { name: ‘M’, type: ‘boolean’ },
    { name: ‘X’, type: ‘boolean’ },
    { name: ‘J’, type: ‘boolean’ },
    { name: ‘V’, type: ‘boolean’ },
    { name: ‘S’, type: ‘boolean’ },
    { name: ‘D’, type: ‘boolean’ },
    { name: ‘medicoNombre’, type: ‘string’ },
    { name: ‘medicoApellido1’, type: ‘string’ },
    { name: ‘medicoApellido2’, type: ‘string’ },
    { name: ‘Estado’, type: ‘string’ },
    { name: ‘Solicitante’, type: ‘string’ },
    { name: ‘Observaciones’, type: ‘string’ }
    ],
    formatdata: function (data) {
    //Envio de la pagina y el tamaño necesarios para la funcion y asi ahorrar velocidad de ejecucion del Script
    return { pagenum: data.pagenum, pagesize: data.pagesize }
    },
    record: ‘Table’,
    url: ‘Paginas/Metodos.aspx/GetTratamientossinRevisar’
    };

    dataAdapter = new $.jqx.dataAdapter(source, { contentType: ‘application/json; charset=utf-8’,
    loadError: function (jqXHR, status, error) {
    alert(error);
    },
    downloadComplete: function () {
    // update the totalrecords count.
    $.ajax({
    url: ‘Paginas/Metodos.aspx/GetSinRevisarRowsCount’,
    contentType: ‘application/json; charset=utf-8’,
    async: false,
    success: function (data) {
    source.totalrecords = (data.d);
    }
    });
    }
    });
    $(“#jqxgrid”).jqxGrid({ source: dataAdapter });
    $(‘#jqxgrid’).jqxGrid({ selectedrowindex: -1 });
    });

    SolicitudesDeCita.click(function (event) {

    //Se muestran los Tratamientos Medulares que tienen solicitud de cita
    source =
    {
    datatype: “xml”,
    datafields: [
    { name: ‘Historia’, type: ‘string’ },
    { name: ‘Nombre’, type: ‘string’ },
    { name: ‘Apellido1’, type: ‘string’ },
    { name: ‘Apellido2’, type: ‘string’ },
    { name: ‘Cic’, type: ‘string’ },
    { name: ‘Fecha_Prescripcion’, type: ‘string’ },
    { name: ‘Procedencia’, type: ‘string’ },
    { name: ‘Tipo_Tratamiento’, type: ‘string’ },
    { name: ‘Turno’, type: ‘string’ },
    { name: ‘Medico_Medulares’, type: ‘int’ },
    { name: ‘Fecha_Alta’, type: ‘string’ },

    { name: ‘Fisioterapeuta’, type: ‘int’ },
    { name: ‘Transporte’, type: ‘boolean’ },
    { name: ‘Fecha_Inicio’, type: ‘string’ },
    { name: ‘Fecha_Revision’, type: ‘string’ },
    { name: ‘Sesion’, type: ‘string’ },
    { name: ‘L’, type: ‘boolean’ },
    { name: ‘M’, type: ‘boolean’ },
    { name: ‘X’, type: ‘boolean’ },
    { name: ‘J’, type: ‘boolean’ },
    { name: ‘V’, type: ‘boolean’ },
    { name: ‘S’, type: ‘boolean’ },
    { name: ‘D’, type: ‘boolean’ },
    { name: ‘medicoNombre’, type: ‘string’ },
    { name: ‘medicoApellido1’, type: ‘string’ },
    { name: ‘medicoApellido2’, type: ‘string’ },
    { name: ‘Estado’, type: ‘string’ },
    { name: ‘Solicitante’, type: ‘string’ },
    { name: ‘Observaciones’, type: ‘string’ }
    ],
    formatdata: function (data) {
    //Envio de la pagina y el tamaño necesarios para la funcion y asi ahorrar velocidad de ejecucion del Script
    return { pagenum: data.pagenum, pagesize: data.pagesize }
    },
    record: ‘Table’,
    url: ‘Paginas/Metodos.aspx/GetTratamientosCitados’
    };

    dataAdapter = new $.jqx.dataAdapter(source, { contentType: ‘application/json; charset=utf-8’,
    loadError: function (jqXHR, status, error) {
    alert(error);
    },
    downloadComplete: function () {
    // update the totalrecords count.
    $.ajax({
    url: ‘Paginas/Metodos.aspx/GetTratamientosCitadosRowsCount’,
    contentType: ‘application/json; charset=utf-8’,
    async: false,
    success: function (data) {
    source.totalrecords = (data.d);
    }
    });
    }
    });

    $(“#jqxgrid”).jqxGrid({ source: dataAdapter });
    $(‘#jqxgrid’).jqxGrid({ selectedrowindex: -1 });
    });

    },
    columns: [
    { text: ‘Historia’, datafield: ‘Historia’, width: ‘9%’, align: ‘center’ },
    { text: ‘Cic’, datafield: ‘Cic’, width: ‘9%’, align: ‘center’ },
    { text: ‘Nombre’, datafield: ‘Nombre’, width: ‘9%’, align: ‘center’ },
    { text: ‘Apellido1’, datafield: ‘Apellido1’, width: ‘9%’, align: ‘center’ },
    { text: ‘Apellido2’, datafield: ‘Apellido2’, width: ‘9%’, align: ‘center’ },
    { text: ‘F. Prescripcion’, datafield: ‘Fecha_Prescripcion’, width: ‘9%’, align: ‘center’, cellsformat: ‘dd/MM/yyyy HH:mm’ },
    { text: ‘Procedencia’, datafield: ‘Procedencia’, width: ‘9%’, align: ‘center’ },
    { text: ‘Tipo de Tratamiento’, datafield: ‘Tipo_Tratamiento’, width: ‘9%’, align: ‘center’ },
    { text: ‘Turno’, datafield: ‘Turno’, width: ‘9%’, align: ‘center’ },
    { text: ‘Medico Medulares’, datafield: ‘Medico_Medulares’, width: ‘9%’, align: ‘center’, cellsrenderer: cellrender },
    { text: ‘Estado’, datafield: ‘Estado’, width: ‘10%’, cellsrenderer: imagerenderer }
    ]
    });

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.