簡體   English   中英

jQuery jTable關閉分頁導致問題

[英]jQuery jTable turned off pagination is causing an issue

我正在使用帶有“幻燈片”效果的jQuery jTable,因此每次單擊一個選項卡時,它都會帶來“幻燈片放置”過渡的數據。 但是,我最近關閉了jQuery jTable中的“分頁”功能,從那時起“滑入”轉換卡在中間,同時發出以下消息“無數據可用”,一旦轉換完成,只有它帶來了數據。

非常奇怪..它在中間卡住了很糟糕,在轉換完成后它只會帶來數據並且是一個主要問題。

有沒有什么方法可以在它帶來數據之前加載ajax? 或者我可以使用任何其他過渡而不是毛躁的'幻燈片'?

我從本地Excel文件中提取數據。 任何幫助都非常感謝:)

滑入轉換代碼:

$(document).on('click', '.PlayStatisticClass', function (e) {

    var $marginLefty = $("div[class='" + this.id + " win-ui-dark slide']")

    if (!$marginLefty.hasClass('slide in')) {

        if (this.id === "PlayStatisticone" || this.id === "PlayStatistictwo" || this.id === "PlayStatisticthree" || this.id === "PlayStatisticfour" || this.id === "PlayStatisticfive"
            || this.id === "PlayStatisticsix" || this.id === "PlayStatisticseven" || this.id === "PlayStatisticeight" || this.id === "PlayStatisticnine") {
            $marginLefty.addClass('registrationFormSlideIn').css('width', "");

        }
        else {


        }

    }
    else {

        $marginLefty.removeClass('slide in').addClass('slide').css('width', 0);

    }
});

jTable查看代碼:我關閉了分頁:

$(document).ready(function () {

    $('#TopPlayedTracksContainer1').jtable({
        title: 'Top Played Genres List',
        paging: false,
        pageSize: 1,
        sorting: true,
        defaultSorting: 'NoOfPlays DESC',
        actions: {
            listAction: '@Url.Action("BilingReportList")'

        },
        fields: {
           TrackID: {
                title: 'Track ID',
                tooltip: 'Track ID'
            },

            TrackName: {
                title: 'Track Name',
                tooltip: 'Track Name',
                key: true,
                create: false,
                edit: false,
                resize: false,
            },
            ArtistName: {
                title: 'Artist Name',
                tooltip: 'Artist Name'
            },
            Times: {
                title: 'Times',
                tooltip: 'Times'
            },
        }
    });

    $('#TopPlayedTracksContainer1').jtable('load');
});

控制器代碼:從本地excel文件獲取數據:

public JsonResult BilingReportList(int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null)
    {
        try
        {
            if (Request.IsAuthenticated == true)
            {
                string Path = @"C:\\5Newwithdate.xls";
                OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= '" + Path + "';Extended Properties=" + (char)34 + "Excel 8.0;IMEX=1;" + (char)34 + "");
                OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", con);
                System.Data.DataTable data = new System.Data.DataTable();
                da.Fill(data);
                con.Close();

                List<TopPlayed> daa = new List<TopPlayed>();
                foreach (DataRow p in data.Rows)
                {
                    TopPlayed top = new TopPlayed()

                    {
                        TrackID = Convert.ToInt32(p.Field<double>("ID")),
                        TrackName = p.Field<string>("Track Name"),
                        ArtistName = p.Field<string>("Artist Name"),
                        Times = Convert.ToInt32(p.Field<double>("NoOfPlays"))
                    };

                    daa.Add(top);
                }

              var newlist = daa.OrderByDescending(i => i.Times).ToList();

              return Json(new { Result = "OK", Records = newlist, TotalRecordCount = daa.Count });

            }
            return Json(new { Result = "ERROR" });
        }
        catch (Exception ex)
        {
            return Json(new { Result = "ERROR", Message = ex.Message });
        }
    }

您需要刪除這些參數:

int jtStartIndex = 0,int jtPageSize = 0,string jtSorting = null

public JsonResult BilingReportList()
{
    try
    {
        if (Request.IsAuthenticated == true)
        {
            string Path = @"C:\\5Newwithdate.xls";
            OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= '" + Path + "';Extended Properties=" + (char)34 + "Excel 8.0;IMEX=1;" + (char)34 + "");
            OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", con);
            System.Data.DataTable data = new System.Data.DataTable();
            da.Fill(data);
            con.Close();

            List<TopPlayed> daa = new List<TopPlayed>();
            foreach (DataRow p in data.Rows)
            {
                TopPlayed top = new TopPlayed()

                {
                    TrackID = Convert.ToInt32(p.Field<double>("ID")),
                    TrackName = p.Field<string>("Track Name"),
                    ArtistName = p.Field<string>("Artist Name"),
                    Times = Convert.ToInt32(p.Field<double>("NoOfPlays"))
                };

                daa.Add(top);
            }

          var newlist = daa.OrderByDescending(i => i.Times).ToList();

          return Json(new { Result = "OK", Records = newlist, TotalRecordCount = daa.Count });

        }
        return Json(new { Result = "ERROR" });
    }
    catch (Exception ex)
    {
        return Json(new { Result = "ERROR", Message = ex.Message });
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM