Author Topic: Remote data requests occur continuously when the number of lists is zero.  (Read 1864 times)

qbsoft

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 7
    • View Profile
Hello.

Remote data requests occur continuously when the number of lists(result from remote data) is zero. I don't know why remote data requests keep happening.

I want to stop the non-stop Remote data requests.

And if the number of remote data is zero, I want to show that 'there is no data' on the grid.

What should I do?

This is my environment.
language: C#, ASP.NET Webform (not MVC)

And Response data: {TotalRecords: 0, CurPage: 1, List: []}

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Quote
Remote data requests occur continuously when the number of lists(result from remote data) is zero. I don't know why remote data requests keep happening.

Please share a jsfiddle so that I can check your code.

Quote
And if the number of remote data is zero, I want to show that 'there is no data' on the grid.

Please include the localization file and this is controlled by the localization string: strNoRows.

It can also be added as a normal option i.e., strNoRows: 'there is no data'
« Last Edit: January 22, 2021, 11:47:13 am by paramvir »

qbsoft

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 7
    • View Profile
Hello.

My sentence can be weird because I used a translator.
Please excuse me.

There is no problem when there is more than one search result.

I didn't ask for so many requests in a row.
When there are zero search results, the request is automatically generated continuously.







This is my code.

I don't know how to use JSfiddle, and I can't provide JSfiddle because my development environment is still only done locally.

Code: [Select]
function funcMainComplete(evt, ui) {
    var rowIndxPage;

    if ($("#hidMainRowIndxPage").val() == "" || $("#hidMainRowIndxPage").val() == undefined) {
        rowIndxPage = 0;
    } else {
        rowIndxPage = Number(rowIndxPage);
    }

    this.setSelection({ rowIndxPage: rowIndxPage });
}

function funcMainRowSelect(evt, ui) {
    if (ui.addList.length > 0) {
        $("#hidUk").val(ui.addList[0].rowData[0]);
        $("#hidMainRowIndxPage").val(ui.addList[0].rowIndxPage);
       
        $("#btnSave").data("mode", "U");
        $("#btnDelete").prop("disabled", false).removeClass("disabled");
    }
}

$(document).ready(function () {
    var gridObj_Provider = {
        showTop: false,
        locale: "ko",
        selectionModel: {
            type: "row",
            mode: "single",
            toggle: false
        },
        scrollModel: {
            autoFit: true
        },
        pageModel: {
            type: "remote",
            rPP: 15,
            rPPOptions: [15, 30, 50, 100, 1000, 10000]
        },
        editable: false,
        complete: funcMainComplete,
        hWrap: false,
        wrap: false,
        height: 630,
        dataModel: {
            location: "remote",
            recIndx: "0",
            dataType: "JSON",
            contentType: "application/json; charset=utf-8",
            url: "/Proc/QbGrid.aspx",
            getData: function (response) {
                return {
                    curPage: response.Data.CurPage,
                    totalRecords: response.Data.TotalRecords,
                    data: response.Data.List
                };
            },
            postData: function () {
                var obj = {
                    gubun: "R",
                    qbgrid_query_template_code: "Provider",
                };
                var searchConditionArr = $("#frmSearch").children().get();
                if (searchConditionArr.length > 0) {
                    searchConditionArr.forEach(function (el) {
                        obj[$(el).attr("name")] = $(el).val();
                    });
                }
                return obj;
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log("error");
                console.log(jqXHR);
                console.log(textStatus);
                console.log(errorThrown);
            }
        },
        colModel: [{
                dataIndx: "state",
                maxWidth: 30,
                minWidth: 30,
                align: "center",
                resizable: false,
                hidden: true,
                title: "",
                menuIcon: false,
                type: "checkbox",
                cls: "ui-state-default",
                sortable: false,
                editor: false,
                dataType: "bool",
                cb: {
                    all: false, //checkbox selection in the header affect current page only.
                    header: true //show checkbox in header.
                }
            },
            {
                dataIndx: "0",
                hidden: "true"
            },
            {
                title: "코드",
                dataType: "string",
                dataIndx: "1",
                hidden: false,
                halign: "center",
                align: "center",
                hvalign: "center",
                valign: "center"

            },
            {
                title: "공급사명",
                dataType: "string",
                dataIndx: "2",
                hidden: false,
                halign: "center",
                align: "center",
                hvalign: "center",
                valign: "center"

            },
            {
                title: "연락처",
                dataType: "string",
                dataIndx: "3",
                hidden: false,
                halign: "center",
                align: "center",
                hvalign: "center",
                valign: "center"

            }
        ],
        rowSelect: funcMainRowSelect,
        hoverMode: "row"
    };
    var qbgrid_Provider = pq.grid("#divQbgrid_Provider", gridObj_Provider);
});


Quote
Please include the localization file and this is controlled by the localization string: strNoRows.

I am using the localization file.
I just want to prevent data requests from occurring continuously when there are zero search results.

Thank you.
« Last Edit: January 25, 2021, 07:02:19 am by qbsoft »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Please use curPage: 0 when there are no records.

Code: [Select]
  {"totalRecords":0,"curPage":0,"data":[]}

Kindly let me know whether it resolves your issue.

qbsoft

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 7
    • View Profile
Thank you for suggesting a solution. Unfortunately, it has not been resolved.

But I found the cause and solution.
The cause is setSelection of the complete function.
After commenting on this part, it was processed normally when the number of lists was 0.

The code that I uploaded yesterday has changed a little bit, but the context is similar.
I have processed to call setSelection only when the number of lists is greater than 0.

Code: [Select]
function funcMainComplete(evt, ui) {
        var listCount = this.pageData().length;

        if (listCount > 0) {
            var rowIndxPage;

            if ($("#hidMainRowIndxPage").val() == undefined || $("#hidMainRowIndxPage").val() == "") {
                rowIndxPage = 0;
            } else {
                rowIndxPage = Number($("#hidMainRowIndxPage").val());
            }

            this.setSelection({ rowIndxPage: rowIndxPage });
        }
    }