dev初识 拖动分组

1.前台代码

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication15.WebForm1" %>

<%@ Register Assembly="DevExpress.Web.v15.1, Version=15.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False">

<SettingsPager PageSize="30" Position="TopAndBottom" SEOFriendly="Enabled" >
</SettingsPager>
<Settings ShowGroupPanel="True" ShowGroupFooter="VisibleAlways"></Settings>
<SettingsBehavior AllowFixedGroups="False" AllowGroup="True" AllowDragDrop="True"/>

<Columns>

<dx:GridViewDataTextColumn FieldName="No" UnboundType="Integer" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Name" UnboundType="String" VisibleIndex="2">

</dx:GridViewDataTextColumn>

</Columns>

<GroupSummary>
<dx:ASPxSummaryItem DisplayFormat="合计:0" FieldName="Name" SummaryType="Sum" />
</GroupSummary>

</dx:ASPxGridView>
</div>
</form>
</body>
</html>

2.后台代码

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication15
{
public class Student
{
public int No { get; set; }
public int Name { get; set; }
}

public static class ListAndTableExt
{
public static DataTable ToDataTable<T>(this List<T> list) where T : class, new()
{
DataColumn column = null;
DataTable table = new DataTable();
List<PropertyInfo> ps = typeof(T).GetProperties().ToList();
ps.ForEach(p =>
{
if (!p.PropertyType.IsGenericType)
{
column = new DataColumn(p.Name, p.PropertyType);
}
else
{
if (p.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
column = new DataColumn(p.Name, Nullable.GetUnderlyingType(p.PropertyType));
}
}
if (column != null)
{
table.Columns.Add(column);
}
});
list.ForEach(obj =>
{
DataRow row = table.NewRow();
ps.ForEach(p =>
{
row[p.Name] = p.GetValue(obj, null);
});
table.Rows.Add(row);
});
return table;
}

public static List<T> ToList<T>(this DataTable table) where T : class, new()
{
List<PropertyInfo> ps = typeof(T).GetProperties().ToList();
List<T> list = new List<T>();
foreach (DataRow row in table.Rows)
{
T obj = new T();
foreach (DataColumn col in table.Columns)
{

ps.ForEach(p =>
{
if (p.Name == col.ColumnName)
{
if (!p.PropertyType.IsGenericType)
{
p.SetValue(obj, string.IsNullOrEmpty(row[p.Name].ToString()) ? null : Convert.ChangeType(row[p.Name].ToString(), p.PropertyType));

}
else
{
if (p.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
p.SetValue(obj, string.IsNullOrEmpty(row[p.Name].ToString()) ? null : Convert.ChangeType(row[p.Name], Nullable.GetUnderlyingType(p.PropertyType)));

}
}
}
});
}
list.Add(obj);

}
return list;

}

}
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Student> stuList = new List<Student>();
for (int i = 0; i < 100; i++)
{
stuList.Add(new Student() { No = i, Name = i });
}
stuList.Add(new Student() { No = 1, Name = 22 });
stuList.Add(new Student() { No = 1, Name = 33 });

DataTable table = stuList.ToDataTable();
ASPxGridView1.DataSource = table;
ASPxGridView1.DataBind();
List<Student> students = table.ToList<Student>();

}
}
}

时间: 2024-08-08 20:23:16

dev初识 拖动分组的相关文章

初识数据库(分组函数)

分组函数 --什么是分组函数 : 可以对结果集中的一组记录进行一次计算 select sal from emp --单行分组函数 --MAX.MIN (最大.最小) --查询emp表中工资最大的和工资最小的工资 select max(sal),min(sal) from emp --SUM.AVG(总和,平均数) --查询员工表中部门号是20的员工工资的总和以及平均工资 select sum(sal),avg(sal) from emp e where e.deptno = '20' --cou

跟我一起学extjs5(19--模块记录的拖放删除、拖放复制新增)

跟我一起学extjs5(19--模块记录的拖放删除.拖放复制新增) 网页其中的拖放(drag-drop)是比較有趣的操作,extjs5中非常好的封装了拖放的动作,也有各种类来支持,可是要学好"拖放"这个东西真是非常难,特别是象我这样英语不好的人.看不太懂官网上的说明,做一个拖放的操作起码得几天的时间. 以下完毕拖放删除的功能.即,选中一条记录或多条记录.然后拖动到"删除"button上.最后松开鼠标进行记录删除的操作.操作步骤: 1.给Grid添加新的配置,使其记录

Dev用于界面按选中列进行分组统计数据源(实用技巧)

如果有用U8的可以明白这个功能就是模仿他的统计功能.我不过是把他造成通用的与适应于DEV的. (效率为6000条数据分组统计时间为3秒左右分组列过多5秒.1000条以下0.几秒,500条下0.00几秒) 前置准备 需求DevExpress.XtraGrid.Views.Grid.GridView 一个grid数据源.原生为DataGridView .Dev重写为gridview 由于Dev的绑定entity与datatable绑定上去Gridview类型会不一致.前者导致gridview.Get

DEV 之 有些控件不允许拖动。

DEV 之 有些控件不允许拖动.  设置一个参数即可解决问题 原文地址:https://www.cnblogs.com/struggle-cs/p/9935939.html

Dev GridView 获取选中分组下的所有数据行 z

现在要在DevExpress 的GridView 中实现这样一个功能.就是判断当前的选中行是否是分组行,如果是的话就要获取该分组下的所有数据信息. 如下图(当选中红框中的分组行事.程序要获取该分组下的所有数据) 实现代码如下: List<int> _gridViewRowIndexs = new List<int>(); //存储GridView 中选中的行索引 private void Test() { int[] rows = gridView1.GetSelectedRows

Dev Express Treelist 同一个树上拖动 改变顺序

using DevExpress.XtraTreeList; using DevExpress.XtraTreeList.Nodes; private void treeList1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { TreeListNode dragNode, targetNode; TreeList tl = sender as TreeList; Point p = tl.PointToClient

DEV Express中NavBarCointrol的使用

尚未对内容进行删减,内容有偏差和冗余,谨慎阅读. 发现在后面,写在前面: 13,之前在Default模式下,之所以很多Appearance属性都起不到作用,是因为Control的LookAndFeel默认选择了UseDefultLookAndFeel. 14,最早在接触该控件的时候,找了很久上调下拉的按钮是怎么出来的,可以设置Control的SkinExplorerBarViewScrollStyle为Button或者是Scroll,即按钮还是滚动条. 一.Control 1,NavBarCon

初识windows程序需要了解的知识点

初识一件事物我们会有陌生,我们慢慢地去了解它就会懂,让我带你们一起了解吧. 一.Form是.Net Framework 定义好的一个最基本的窗体类,具有窗体基本属性和方法 属性              说明 MaximizeBox    确定窗体标题栏的右上角------是否有最大化的框-----------默认为True ShowInTaskbar     确定窗体是否出现在----------任务栏中------默认为True StartPosition     确定窗体第一次出现的---

DEV GridControl小结【转载】

1. 如何解决单击记录整行选中的问题 View->OptionsBehavior->EditorShowMode 设置为:Click 2. 如何新增一条记录 (1).gridView.AddNewRow() (2).实现 gridView_InitNewRow 事件 3.如何解决 GridControl 记录能获取而没有显示出来的问题 gridView.populateColumns(); 4.如何让行只能选择而不能编辑(或编辑某一单元格) (1).View->OptionsBehavi