ASPxGridView – header rowspan and colspan

1. Để nhóm các column vào một nhóm trên Header ta dùng GridViewBandColumn

<dxwgv:GridViewBandColumn Caption="Lượt thực hiện" VisibleIndex="4">
<HeaderStyle HorizontalAlign="Center" />
<Columns>
<dxwgv:GridViewDataTextColumn Caption="hoàn chỉnh <br /> (A-B)" FieldName="VPXB"
Name="VPXB" VisibleIndex="5" Width="60">
<HeaderStyle HorizontalAlign="Center" />
<CellStyle HorizontalAlign="Center">
</CellStyle>
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn Caption="quay đầu" FieldName="VPGiamTocDotNgot" Width="60"
Name="VPGiamTocDotNgot" VisibleIndex="6">
<HeaderStyle HorizontalAlign="Center" />
<CellStyle HorizontalAlign="Center">
</CellStyle>
</dxwgv:GridViewDataTextColumn>
</Columns>
</dxwgv:GridViewBandColumn>

2. Chi tiết tại đây

http://demos.devexpress.com/ASPxGridViewDemos/Columns/Bands.aspx

Advertisements

PopupControl trong devexpress và UpdateProgress

<asp:UpdateProgress runat=”server” ID=”UpdateProgress” AssociatedUpdatePanelID=”PanelSearch” DisplayAfter=”0″ DynamicLayout=”false”>
<ProgressTemplate>
<div id=”progressBackgroundFilter”></div>
<div id=”processMessage”>Loading…<br /><img alt=”Loading” src=”Images/progress.gif” /></div>
</ProgressTemplate>
</asp:UpdateProgress>

<dxpc:ASPxPopupControl ID=”ASPxPopupReport” runat=”server” HeaderText=”Báo cáo”

Modal=”True” PopupHorizontalAlign=”WindowCenter” PopupVerticalAlign=”WindowCenter”
ContentUrl=”~/WebUI/Bus/reportMergeColumn.aspx” CloseAction=”CloseButton”
Width =”900px” Height =”570px” AllowDragging=”True” >
</dxpc:ASPxPopupControl>

<asp:UpdatePanel ID=”UpdatePanel_FilerReport” runat=”server”>
<ContentTemplate>
<div style=”text-align: center;”>
<dxpc:ASPxPopupControl ID=”ASPxPopupReport” runat=”server” HeaderText=”Report” Modal=”True”
AllowDragging=”true” PopupHorizontalAlign=”WindowCenter” PopupVerticalAlign=”WindowCenter”
ContentUrl=”~/WebUI/BaoCao/rptReportViewBasicLandscape.aspx” Height=”600px” Width=”1200px” CloseAction=”CloseButton”>
</dxpc:ASPxPopupControl>
</div>
</ContentTemplate>
</asp:UpdatePanel>

<TotalSummary>
<dx:ASPxSummaryItem FieldName = “STT” ShowInColumn= “STT” SummaryType =”Sum” DisplayFormat= “Tổng” />
<dx:ASPxSummaryItem FieldName = “NoOfFlights” ShowInColumn= “NoOfFlights” SummaryType =”Sum” DisplayFormat=”{0:0.##}”/>
<dx:ASPxSummaryItem FieldName = “AirConditionerOff” ShowInColumn= “AirConditionerOff” SummaryType =”Sum” DisplayFormat=”{0:0.##}” />
<dx:ASPxSummaryItem FieldName = “NoOfSpeedOver” ShowInColumn= “NoOfSpeedOver” SummaryType =”Sum” DisplayFormat=” {0:0.##}”/>
<dx:ASPxSummaryItem FieldName = “NoVisitStation” ShowInColumn= “NoVisitStation” SummaryType =”Sum” DisplayFormat=”{0:0.##}”/>
<dx:ASPxSummaryItem FieldName = “XBSom” ShowInColumn= “XBSom” SummaryType =”Sum” DisplayFormat=”{0:0.##}”/>
<dx:ASPxSummaryItem FieldName = “XBMuon” ShowInColumn= “XBMuon” SummaryType =”Sum” DisplayFormat=”{0:0.##}”/>
<dx:ASPxSummaryItem FieldName = “VBSom” ShowInColumn= “VBSom” SummaryType =”Sum” DisplayFormat=”{0:0.##}”/>
<dx:ASPxSummaryItem FieldName = “VBMuon” ShowInColumn= “VBMuon” SummaryType =”Sum” DisplayFormat=”{0:0.##}”/>
<dx:ASPxSummaryItem FieldName = “NoOfWrongRoute” ShowInColumn= “NoOfWrongRoute” SummaryType =”Sum” DisplayFormat=”{0:0.##}”/>
</TotalSummary>

protected void ResetControl()
{
btnTimKiem.Enabled = true;
btnBaoCao.Enabled = false;
GridViewAL.DataSource = null;
GridViewAL.DataBind();

}

DevExpress ComboBox AutoComplete

<dx:ASPxComboBox runat=”server” ID=”ASPxComboBox”  ClientInstanceName=”cmbCity” OnCallback=”CmbCity_Callback”
DropDownStyle=”DropDown”    TextField=”City”
ValueField=”City” IncrementalFilteringMode=”StartsWith”>
</dx:ASPxComboBox>

1. IncrementalFilteringMode=”StartsWith
– Tìm kiếm theo dạng kí tự bắt đầu

2. IncrementalFilteringMode=”Contains
– Tìm kiếm theo dạng kí tự chứa nó

DataItemTemplate trong DevExpress GridView

1. aspx

<dx:ASPxGridView ID=”ASPxGridView1″ runat=”server” AutoGenerateColumns=”False” KeyFieldName=”ID”
Width=”300px” ClientInstanceName=”grid”
onhtmlrowprepared=”ASPxGridView1_HtmlRowPrepared”>
<Columns>
<dx:GridViewDataTextColumn FieldName=”ID” ReadOnly=”True” VisibleIndex=”0″ Width=”50px”>
<EditFormSettings Visible=”False” />
</dx:GridViewDataTextColumn>
<dx:GridViewDataColumn FieldName=”Vehicle” Width=”110px”>
<DataItemTemplate>
<dx:ASPxComboBox id=”cboVehicle” runat=”Server” Width=”100px” >
</dx:ASPxComboBox>
</DataItemTemplate>
</dx:GridViewDataColumn>
</Columns>
</dx:ASPxGridView>

2. Code-Behind

protected void ASPxGridView1_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e)
{
if (e.RowType != GridViewRowType.Data) return;

ASPxComboBox cbo = ASPxGridView1.FindRowCellTemplateControl(e.VisibleIndex, null, “cboVehicle”) as ASPxComboBox;

cbo.DataSource = this.ListVehicle;
cbo.ValueField = “VehicleID”;
cbo.TextField = “BienSoXe”;
cbo.DataBind();

cbo.SelectedItem = cbo.Items.FindByValue(e.GetValue(“Vehicle”).ToString());
}

 

3. Xem thêm tại các link sau

a. populate combobox on fly in gridview
b. Grid Editing – Edit Modes
c. ASPxGridView EditForm & Validation
d. ASPxGridView DisplayMode – combobox on the fly
e. GridViewDataColumn.DataItemTemplate Property
f. Custom client-side logic implementation in the grid with multi-row editing
g. Change row and data cell styles using events
h. GridView RowDataBound event

Phân trang DevExpress ASPxGridView sử dụng ObjectDataSource

1. aspx
<dx:ASPxGridView ID="grid" runat="server" DataSourceForceStandardPaging="True"
AutoGenerateColumns="False"
                DataSourceID="ods" KeyFieldName="ContactID">
                <Columns>
                   <dx:GridViewDataTextColumn FieldName="FirstName" VisibleIndex="1">
                    </dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn FieldName="LastName" VisibleIndex="2">
                    </dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn FieldName="EmailAddress" VisibleIndex="3>
                    </dx:GridViewDataTextColumn>
                </Columns>
            </dx:ASPxGridView>
            <asp:ObjectDataSource ID="ods" runat="server" SortParameterName="sortColumn"
EnablePaging="true"
                StartRowIndexParameterName="startRecord" MaximumRowsParameterName="maxRecords"
                SelectCountMethod="GetPeopleCount" SelectMethod="GetPeople"
TypeName="People"></asp:ObjectDataSource>

2. Business Object
public class People
{
public static DataTable GetPeople(Int32 startRecord, Int32 maxRecords, String sortColmn)
private static void VerifySortColumns(string sortColumns);
public static Int32 GetPeopleCount() ;
}
3. Chi tiết tại:
http://www.devexpress.com/Support/Center/p/E2672.aspx

4.Paging and filtering with objectdatasource
http://www.devexpress.com/Support/Center/p/B136402.aspx?searchtext=LinqDataSourceServerMode&p=T4|P5|57

Phân trang DevExpress ASPxGridView

1. http://community.devexpress.com/forums/t/56484.aspx?PageIndex=1

2. http://community.devexpress.com/blogs/ctodx/archive/2007/08/04/put-xtragrid-into-overdrive-by-using-xpo-with-large-datasets.aspx

3. http://www.devexpress.com/Support/Center/e/E166.aspx

4. http://www.devexpress.com/Support/Center/p/E2672.aspx (Đọc thằng này)

5. http://www.codeproject.com/Messages/3871645/ObjectDataSource-for-DevExpress-ASPxGtridView-with.aspx (Đọc thằng này)

DevExpress ASPxGridView Custom Paging

1. aspx

<form id=”form1″ runat=”server”>
<div style=”width: 100%; margin-top: 50px;”>
<div style=”width: 100%; margin: 0 auto;”>
<dx:ASPxGridView ID=”grvCustomer” runat=”server” AutoGenerateColumns=”False” KeyFieldName=”CustomerID”
Width=”500″>
<SettingsPager Visible=”False”>
</SettingsPager>
<Border BorderWidth=”1px” BorderStyle=”Solid”></Border>
<Columns>
<dx:GridViewDataTextColumn FieldName=”CustomerID” VisibleIndex=”1″ Caption=”Mã khách”>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName=”CompanyName” VisibleIndex=”2″ Caption=”Tên công ty”>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName=”ContactName” VisibleIndex=”3″ Caption=”Tên liên hệ”>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName=”ContactTitle” VisibleIndex=”4″ Caption=”Tiêu đề”>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName=”Address” VisibleIndex=”5″ Caption=”Địa chỉ”>
</dx:GridViewDataTextColumn>
</Columns>
</dx:ASPxGridView>
<div style=”width: 498px; height:30px; border: solid 1px #999; border-top: none;”>
<div style=”float: right;”>
<dx:ASPxPager ID=”ASPxPager1″ ItemCount=”3″ ItemsPerPage=”1″ runat=”server” NumericButtonCount=”5″
CurrentPageNumberFormat=”{0}” OnPageIndexChanged=”ASPxPager1_PageIndexChanged”>
<LastPageButton Visible=”True”>
</LastPageButton>
<AllButton Text=”Tất cả”>
</AllButton>
<FirstPageButton Visible=”True”>
</FirstPageButton>
<Summary Position=”Inside” Text=”Trang {0} của {1} ” />
<CurrentPageNumberStyle BackColor=”#FFFF99″ ForeColor=”Red”>
<Paddings PaddingLeft=”5″ PaddingRight=”5″ PaddingTop=”2″ PaddingBottom=”2″ />
<Border BorderColor=”#CC0000″ BorderStyle=”Solid” BorderWidth=”1px” />
</CurrentPageNumberStyle>
</dx:ASPxPager>
</div>
</div>
</div>
</div>
</form>

2. aspx.cs

public partial class GridViewPaging : System.Web.UI.Page
{
public int PageSize
{
get
{
return (base.ViewState[“PageSize”] != null) ? (int)base.ViewState[“PageSize”] : 10;
}
set
{
base.ViewState[“PageSize”] = value;
}
}

public int CurrentPage
{
get
{
return (base.ViewState[“CurrentPage”] != null) ? (int)base.ViewState[“CurrentPage”] : 0;
}
set
{
base.ViewState[“CurrentPage”] = value;
}
}

public int RowCount
{
get { return (base.ViewState[“RowCount”] != null) ? (int)base.ViewState[“RowCount”] : 0; }
set { base.ViewState[“RowCount”] = value; }

}

protected void Page_Load(object sender, EventArgs e)
{
RegisterRequiresControlState(ASPxPager1);

if (!Page.IsPostBack)
{
BindData();
}

}

public void BindData()
{
int count = 0;

DataTable dtSource = DBUtils.GetDataPaging(PageSize, CurrentPage, ref count);
this.RowCount = count;

ASPxPager1.ItemCount = count;
ASPxPager1.ItemsPerPage = this.PageSize;

grvCustomer.DataSource = dtSource;
grvCustomer.DataBind();
}
protected void ASPxPager1_PageIndexChanged(object sender, EventArgs e)
{
this.CurrentPage = ASPxPager1.PageIndex;

BindData();
}
}