FineUI 官方论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

本论坛已关闭(禁止注册、发帖和回复)
请移步 三石和他的朋友们

FineUI首页 WebForms - MVC & Core - JavaScript 常见问题 - QQ群 - 十周年征文活动

FineUI(开源版) 下载源代码 - 下载空项目 - 获取ExtJS - 文档 在线示例 - 版本更新 - 捐赠作者 - 教程

升级到 ASP.NET Core 3.1,快、快、快! 全新ASP.NET Core,比WebForms还简单! 欢迎加入【三石和他的朋友们】(基础版下载)

搜索
查看: 3705|回复: 4
打印 上一主题 下一主题

表格分页和高亮显示同时使用时出现问题

[复制链接]
跳转到指定楼层
楼主
发表于 2014-4-21 17:42:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
反馈BUG
程序版本: fineui v3.3.0.0
浏览器: IE8 
BUG截图:
BUG地址: -
表格分页和高亮显示同时使用时出现问题,如果不分页只是高亮显示没有问题,如果只是分页不高亮显示也没有问题.
错误显示第528行:Ext.get(row).first().addClass('highlight');

前台代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        .highlight
        {
          background-color:Green;
        }
        .highlight .x-grid3-col
        {
            background-image: none;
        }
        
        .x-grid3-row-selected .highlight
        {
            background-color: yellow;
        }
        .x-grid3-row-selected .highlight .x-grid3-col
        {
            background-image: none;
        }
        
     
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <xageManager ID="pm_Main" AutoSizePanelID="rpnl_Main" runat="server" FormLabelWidth="1"   FormOffsetRight="4px" />
    <x:RegionPanel ID="rpnl_Main" ShowBorder="false" runat="server">
        <Regions>
            <x:Region ID="rgn_Top" Split="true" EnableSplitTip="true" Height="50px"  Margins="0 0 0 0" ShowHeader="true" Position="top"  runat="server" EnableBackgroundColor="True" ShowBorder="false" Title="待归还的单">
                <Items>
                <x:Form ID="Form5" ShowBorder="False" BodyPadding="5px" EnableBackgroundColor="true" ColumnWidth="100%"   ShowHeader="false" runat="server" Height="75px"  >
                    <Rows>
                        <x:FormRow ColumnWidths="115px 115px  115px 105px 45px">
                            <Items>
                               <x:TextBox ID="txtPartNo" runat="server" ShowLabel="false" EmptyText="编号" Width="110px"></x:TextBox>
                               <x:TextBox ID="txtName" runat="server" ShowLabel="false" EmptyText="编号" Width="110px"></x:TextBox>
                               <xropDownList ID="txtApplicant"  ShowLabel="false"  runat="server" Width="110px"></xropDownList>
                               <xropDownList ID="txtAppDept" ShowLabel="false"  runat="server" Width="100px"></xropDownList>
                               <x:Button ID="txtSearch" Text="查询" runat="server" ></x:Button>   
                            </Items>
                        </x:FormRow>
                    </Rows>
                </x:Form>
                </Items>         
            </x:Region>
            
            <x:Region ID="ren_Center" ShowHeader="false" Layout="Fit" Position="Center" Margins="2 2 2 0" runat="server" Title="待审批的单" >  
                <Items>
                        <x:Grid ID="Grid1" ShowBorder="false" AutoScroll="true"  ShowHeader="false" runat="server" EnableTextSelection="true"
                               DataKeyNames="id"  EnableRowNumber="True"  
                             AllowPaging="true"  PageSize="25">
                        <Columns>
                            <x:WindowField  Width="40px" WindowID="Window1" HeaderText="归还" Text="归还" DataIFrameUrlFields="id,Partno"
                               DataIFrameUrlFormatString="./P_Return_Submit.aspx?ID={0}&artNo={1}" IFrameUrl="~/alert.aspx"
                               DataWindowTitleField="id" DataWindowTitleFormatString="Return"  />
                            <x:BoundField Width="80px" DataField="partno"  HeaderText="编号" />
                            <x:BoundField Width="80px" DataField="name"  HeaderText="名称" />
                            <x:BoundField Width="60px" DataField="modelinch"  HeaderText="型号(英)" />
                            <x:BoundField Width="60px" DataField="modelm"  HeaderText="型号(公)" />
                            <x:BoundField Width="40px" DataField="category"  HeaderText="类别" />
                            <x:BoundField Width="60px" DataField="precisionlevel"  HeaderText="精度等级" />
                            <x:BoundField Width="60px" DataField="approveqty"  HeaderText="批准数量" />
                            <x:BoundField Width="80px" DataField="approvedate" DataFormatString="{0:yyyy-MM-dd}"  HeaderText="批准日期" />
                            <x:BoundField Width="80px" DataField="continuedate"  DataFormatString="{0:yyyy-MM-dd}"  HeaderText="续借日期" />
                            <x:BoundField Width="50px" DataField="apptype"  HeaderText="用途" />
                            <x:BoundField Width="150px" DataField="appremark"  HeaderText="备注" />
                            <x:BoundField Width="80px" DataField="applicant"  HeaderText="申请人" />
                            <x:BoundField Width="60px" DataField="appdept"  HeaderText="申请部门" />
                            <x:BoundField Width="80px" DataField="appdate" DataFormatString="{0:yyyy-MM-dd}" HeaderText="申请日期" />
                        </Columns>
                    </x:Grid>
                    <x:HiddenField ID="highlightRows" runat="server">    </x:HiddenField>
                  
                </Items>
            </x:Region>
        </Regions>
    </x:RegionPanel>  
   
    <x:Window ID="Window1" Title="Form" Popup="false" EnableIFrame="true" runat="server"
        EnableResize="true" Target="Self"  IsModal="True" Width="550px" Height="450px">
    </x:Window>
    </form>
    <script type="text/javascript">
        var highlightRowsClientID = '<%= highlightRows.ClientID %>';
      
        var gridClientID = '<%= Grid1.ClientID %>';
        function highlightRows() {
            var highlightRows = X(highlightRowsClientID);
            var grid = X(gridClientID);
            grid.el.select('.x-grid3-row table.highlight').removeClass('highlight');
            Ext.each(highlightRows.getValue().split(','), function (item, index) {
                if (item !== '') {
                    var row = grid.getView().getRow(parseInt(item, 10));
                    Ext.get(row).first().addClass('highlight');
                }
            });
        }

        // 页面第一个加载完毕后执行的函数
        function onReady() {
            var grid = X(gridClientID);
            grid.addListener('viewready', function () {
                highlightRows();
            });
        }
        // 页面AJAX回发后执行的函数
        function onAjaxReady() {
            highlightRows();
        }
    </script>

后台代码:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using FineUI;
public partial class MTMS_P_Return : System.Web.UI.Page
{
    SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["SqlMTMS"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"] == "" | Session["username"] == null)
        {
            Response.Redirect("../login.aspx?sys=MTMS");
        }
          if (!IsPostBack)
          {
                 if (!(Session["username"] != "" && Session["username"] != null))
                    {
                        Response.Write("<script> window.top.location.href='../login.aspx?sys=MTMS';</script>");
                    }
                 string sqlCreator = "select distinct applicant from app_form where status='Out' order by applicant";
                 string sqlCreateDept = "select distinct appdept from app_form where status='Out' order by appdept";
                  
                    SqlCommand myCreator = new SqlCommand(sqlCreator, myConnection);
                    SqlCommand myCreateDept = new SqlCommand(sqlCreateDept, myConnection);
                  
                    myConnection.Open();

                    SqlDataAdapter myDataCreator = new SqlDataAdapter(myCreator);
                    DataTable myDataC = new DataTable();
                    myDataCreator.Fill(myDataC);
                    txtApplicant.DataTextField = "Applicant";
                    txtApplicant.DataValueField = "Applicant";
                    txtApplicant.DataSource = myDataC;
                    txtApplicant.DataBind();
                    txtApplicant.Items.Insert(0, new ListItem("申请人", ""));

                    SqlDataAdapter myDataCreateDept = new SqlDataAdapter(myCreateDept);
                    DataTable myDataD = new DataTable();
                    myDataCreateDept.Fill(myDataD);
                    txtAppDept.DataTextField = "appDEPT";
                    txtAppDept.DataValueField = "appDEPT";
                    txtAppDept.DataSource = myDataD;
                    txtAppDept.DataBind();
                    txtAppDept.Items.Insert(0, new ListItem("申请部门", ""));
                  
                    
                    myConnection.Close();
               
                   // loadDetail(" and 1=1 ");
        }
        else
        {
           // if (Request.Form["__EVENTTARGET"] == txtPartNo.ClientID  && Request.Form["__EVENTARGUMENT"] == "specialkey")
            //    {
                    btn_search();
             //   }
         
        }
          loadDetail(" and 1=1 ");
    }
    protected void btn_SearchClick(object sender, EventArgs e)
    {
        btn_search();
    }
    protected void btn_search()
    {
        string sqlstr1 = "";
        if (txtPartNo.Text != "")
        {
            sqlstr1 += " and a.partno like '%" + txtPartNo.Text + "%'";
        }
        if (txtName.Text != "")
        {
            sqlstr1 += " and a.name like '%" + txtName.Text + "%'";
        }
        if (txtApplicant.SelectedValue != "")
        {
            sqlstr1 += " and b.Applicant='" + txtApplicant.SelectedText + "'";
        }
        if (txtAppDept.SelectedValue != "")
        {
            sqlstr1 += " and b.AppDept='" + txtAppDept.SelectedText + "'";
        }
        if (sqlstr1 == "")
        {
            sqlstr1 = " and 1=1 ";
        }
        // Form5.Reset();
        loadDetail(sqlstr1);
    }
    public void loadDetail(string txtSql)  //加载详细项目待审批的单
    {
        string sqlParts = "";
        string sqlStore = "select name from d_admin where name='" + Session["username"].ToString() + "' and role='Store Admin' ";  //仓库管理员
        SqlCommand cmStore = new SqlCommand(sqlStore, myConnection);
        myConnection.Open();
        SqlDataReader myStore = cmStore.ExecuteReader();
        if (myStore.Read())
        {
            sqlParts = "select a.partno,a.name,a.modelinch,a.modelm,a.category,a.precisionlevel,b.id,b.appremark,b.apptype,"
                         + " b.status,b.applicant,b.appdept,b.appdate,b.approveqty,b.approvedate,b.continuedate  from partsinfo a,app_form b "
                         + " where a.partno=b.partno  and b.status='Out' " + txtSql + "   order by b.appdate desc, b.status";
        }
        else
        {
            sqlParts = "select a.partno,a.name,a.modelinch,a.modelm,a.category,a.precisionlevel,b.id,b.appremark,b.apptype,"
                       + " b.status,b.applicant,b.appdept,b.appdate,b.approveqty,b.approvedate,b.continuedate  from partsinfo a,app_form b "
                       + " where a.partno=b.partno and b.status='Out' and applicant='" + Session["username"].ToString() + "'  order by b.status";
            Grid1.Columns[0].Hidden = true;
        }
        myStore.Close();
        
        SqlCommand myParts = new SqlCommand(sqlParts, myConnection);
        SqlDataAdapter mydetail = new SqlDataAdapter(myParts);
        DataSet myds = new DataSet();
        mydetail.Fill(myds, "partsinfo");
        Grid1.DataSource = myds;
        Grid1.DataBind();
        myConnection.Close();
    }
    //改变背景颜色
    protected void Grid1_RowDataBound(object sender, FineUI.GridRowEventArgs e)
    {
        DataRowView row = e.DataItem as DataRowView;
        if (row != null)
        {
            DateTime tDelay = DateTime.Now;
            if (row["continuedate"].ToString() == "")
            {
                tDelay = Convert.ToDateTime(row["approvedate"]);
            }
            else
            {
                tDelay = Convert.ToDateTime(row["continuedate"]);
            }
                if (getDays(tDelay) > 6)
                {
                    highlightRows.Text += e.RowIndex.ToString() + ",";
                }
        }
    }

    //获取两个日期之间的天数(自定义方法)
    protected int getDays(DateTime Adate)
    {
        DateTime dt1 = Adate;                         // Convert.ToDateTime("2010-12-06 08:00:00");//初始化一个日期
        DateTime dt2 = DateTime.Now;                  //获取今天日期
        System.TimeSpan ts = dt2.Subtract(dt1);       //TimeSpan得到dt1和dt2的时间间隔
        int countday = ts.Days;                       //获取两个日期间的总天数
      
        return countday;
    }
  protected void Grid1_PageIndexChange(object sender, FineUI.GridPageEventArgs e)
    {
        Grid1.PageIndex = e.NewPageIndex;
        btn_search();
    }
}

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
沙发
 楼主| 发表于 2014-4-24 11:48:30 | 只看该作者
我知道问题出在哪里,但不知道怎么解决。
我不分页时是第601行,602行。。。高亮显示,等我分页后每页只有25行,所以找不到601行。
请三石兄帮忙。
板凳
发表于 2014-4-24 13:52:04 | 只看该作者
Xiaonn 发表于 2014-4-24 11:48
我知道问题出在哪里,但不知道怎么解决。
我不分页时是第601行,602行。。。高亮显示,等我分页后每页只有2 ...

Ext.get(row).first().addClass('highlight');

你判读下取到的 Ext.get(row) 是否为空。

如果还存在问题,请把你的例子放在空项目中重现,方便大家调试
地板
 楼主| 发表于 2014-4-24 15:54:47 | 只看该作者
sanshi 发表于 2014-4-24 13:52
Ext.get(row).first().addClass('highlight');

你判读下取到的 Ext.get(row) 是否为空。

是空值,应为每页都没有601行,
5#
 楼主| 发表于 2014-4-24 16:55:00 | 只看该作者
Xiaonn 发表于 2014-4-24 15:54
是空值,应为每页都没有601行,


如果,我设置第一行和第二行高亮显示,每页第一第二行都高亮显示,而不是第一页的第一行和第二行高亮显示。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|FineUI 官方论坛 ( 皖ICP备2021006167号-1 )

GMT+8, 2024-6-18 02:49 , Processed in 0.059169 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表