天道酬勤,学无止境

How to filter ASPxGridView by text that is different from data source

I have a DevExpress AspGridView on my webpage and I am using the filter row that is included. The problem I am having is that I am changing the value of the display text from an integer to some corresponding string in an array (the integer becomes the array index), however the filter row doesn't sort by the new display text value. When typing something into the filter row, it tries to search for integers rather than strings.

Here is the code used to change the text in the cell

gv.HtmlDataCellPrepared += (sender, e) =>
        {
            if (e.DataColumn.FieldName == "FOO_STATUS")
            {
                e.Cell.Text = STATUS[int.Parse(e.GetValue("FOO_STATUS").ToString())];
            }
        };

评论

Specify custom grid cells' text via the ASPxGridView.CustomColumnDisplayText event (instead of the ASPxGridView.HtmlDataCellPrepared one) and set the corresponding column's Settings.FilterMode property to DisplayText:

<dx:ASPxGridView ... OnCustomColumnDisplayText="OnCustomColumnDisplayText">
    <Columns>
        ...
        <dx:GridViewDataSpinEditColumn FieldName="FOO_STATUS">
            <Settings FilterMode="DisplayText" />
        </dx:GridViewDataSpinEditColumn>
    </Columns>
</dx:ASPxGridView>

//CS    
protected void OnCustomColumnDisplayText(object sender, ASPxGridViewColumnDisplayTextEventArgs e) {
    if (e.Column.FieldName == "FOO_STATUS") {
        e.DisplayText = STATUS[int.Parse(e.GetFieldValue("FOO_STATUS").ToString())];
    }
}

'VB
Protected Sub OnCustomColumnDisplayText(ByVal sender As Object, ByVal e As ASPxGridViewColumnDisplayTextEventArgs)
    If e.Column.FieldName Is "FOO_STATUS" Then
        e.DisplayText = STATUS(Integer.Parse(e.GetFieldValue("FOO_STATUS").ToString()))
    End If
End Sub

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

相关推荐
  • 在 Devexpress ASPxGridView 中查找控件(Finding controls within Devexpress ASPxGridView)
    问题 我有一个包含 ASPxGridView 和 ASPxCheckBox 和 Label 的代码,如下所示: <dx:ASPxGridView ID="gvTableSearchHomes" runat="server" DataSourceID="XmlHomes" Width="341px" CssClass="tableViewSearchGrid" ClientInstanceName="gvTableSearchHomes" AutoGenerateColumns="False" EnableRowsCache="false" KeyFieldName="ID"> <%--<Columns>--%> <%-- DXCOMMENT: Within ASPxGridView, add a column whose values will participate in filtering --%> <%--<dx:GridViewDataTextColumn FieldName="Address"> <PropertiesTextEdit NullText="Search your home"></PropertiesTextEdit> <Settings AllowAutoFilterTextInputTimer="True" AutoFilterCondition=
  • Finding controls within Devexpress ASPxGridView
    I have a code that contains an ASPxGridView and a ASPxCheckBox and Label within in like: <dx:ASPxGridView ID="gvTableSearchHomes" runat="server" DataSourceID="XmlHomes" Width="341px" CssClass="tableViewSearchGrid" ClientInstanceName="gvTableSearchHomes" AutoGenerateColumns="False" EnableRowsCache="false" KeyFieldName="ID"> <%--<Columns>--%> <%-- DXCOMMENT: Within ASPxGridView, add a column whose values will participate in filtering --%> <%--<dx:GridViewDataTextColumn FieldName="Address"> <PropertiesTextEdit NullText="Search your home"></PropertiesTextEdit> <Settings
  • ObjectDataSource 中的 DevExpress AspxGridView 过滤器(DevExpress AspxGridView filter in ObjectDataSource)
    问题 DevExpress AspxGridView 的另一个问题:) 上下文: 一页在 Page 中,自定义控件在自定义控件中,一个 AspxDropDown AspxDropDown有一个DropDownWindowTemplate 在DropDownItemTemplate ,我添加了一个GridView和一个启用分页/排序/过滤的ObjectDataSource 在处理ObjectDataSource的选择事件时,我应该为数据源设置过滤器参数。 过滤器参数应该来自FilterRow的AspxGridView (最好使用AspxGridView.FilterExpression属性)。 问题: AspxGridView.FilterExpression属性未设置为正确的值(由用户设置)。 有没有人找到我在这里尝试做的事情的一个很好的实现? 谢谢一堆。 :) 回答1 我终于设法解决了这个问题。 不是一个好的解决方案,但仍然是一种解决方法。 所以..“解决方案”是在每个 AfterPerformCallback 事件上对网格进行数据绑定。 void grid_AfterPerformCallback(object sender, ASPxGridViewAfterPerformCallbackEventArgs e) { ((DevExpress.Web.ASPxGridView
  • DevExpress AspxGridView filter in ObjectDataSource
    Yet another problem with DevExpress AspxGridView :) The context: One Page In the Page, a custom control In the custom Control, a AspxDropDown The AspxDropDown has a DropDownWindowTemplate In the DropDownItemTemplate, I add a GridView and a paging/sorting/filtering enabled ObjectDataSource When handling the selecting event of the ObjectDataSource, I should set filter parameters for the datasource. There filter parameters should come from the FilterRow of the AspxGridView (preferably using the AspxGridView.FilterExpression property). The problem: the AspxGridView.FilterExpression property is not
  • Devexpress ASPxGridView GetSelectedFieldValues 无法获取值(Devexpress ASPxGridView GetSelectedFieldValues Can't get values)
    问题 我正在使用带有分页的 gridview。 我的网格有一个命令列,并且ShowSelectCheckbox设置为 true。 我在Page_Load事件中使用条件 [ if (!IsCallback) ] 将DataTable绑定到网格。 所以当我更改页面索引数据时会丢失。 之后我编写了绑定代码到网格的PageIndexChanged事件。 现在它就像魅力一样。 但是GetSelectedFieldValues仅在发生SelectionChanged事件时在第一页起作用。 例如,当我在第一页选择一行时,它会获取我想要的字段值。 但是当我更改 pageindex GetSelectedField时无法获取字段值。 它提醒空文本。 如果我在第二页索引处选择一行,它也可以在该页上工作,但是当我更改页面索引时,它又坏了。 顺便说一句,当我在没有!IsCallback条件的情况下在PageLoad事件中绑定网格时,它可以工作,但我无法在Page_Load事件中绑定它,因为其他控件必须更改查询等数据。 这是我的 javascript 函数,它会提醒选定的值 <ClientSideEvents SelectionChanged="function(s, e) { grid.GetSelectedFieldValues('SDNO;SANTRAL',alert); }" />
  • 在 ASPxClientGridView.ApplyFilter 执行其工作后触发的客户端事件(Client side event that fires after ASPxClientGridView.ApplyFilter performs its work)
    问题 此链接解释了如何通过 ASPxGridView.AfterPerformCallback 事件在服务器端处理它: http://www.devexpress.com/Support/Center/p/Q274366.aspx 我该如何在客户端处理它? 我正在开发一个自定义服务器控件,并且我的控件上有这个客户端功能: applyFilterToGridView: function () { this.theGridView.ApplyFilter(this.filterCondition); this.filterAppliedEvent(); } 因为 ApplyFilter 做了回调,所以 this.filterAppliedEvent() 没有在正确的时间调用,而这应该是在过滤完成之后。 this.filterAppliedEvent() 是一个客户端函数。 应用过滤器后会触发此事件: protected void theGridView_AfterPerformCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewAfterPerformCallbackEventArgs e) { if (e.CallbackName == "APPLYFILTER") { } } 有什么方法可以告诉客户端从
  • Client side event that fires after ASPxClientGridView.ApplyFilter performs its work
    This link explains how to handle it on the server side via the ASPxGridView.AfterPerformCallback event: http://www.devexpress.com/Support/Center/p/Q274366.aspx How can I handle it on the client side? I am working on a custom server control and I have this client side function on my control: applyFilterToGridView: function () { this.theGridView.ApplyFilter(this.filterCondition); this.filterAppliedEvent(); } Because ApplyFilter does a callback, this.filterAppliedEvent() is not called at the right time which should be after the filtering is complete. this.filterAppliedEvent() is a client side
  • Devexpress ASPxGridView GetSelectedFieldValues Can't get values
    I'm using a gridview with paging. My grid has a command column and ShowSelectCheckbox is set to true. I bind DataTable to grid at Page_Load event with the condition [ if (!IsCallback) ]. So when i change page index data is lost. After that i wrote bind code to grid's PageIndexChanged event. Now it works like charm. But GetSelectedFieldValues works only at first page when SelectionChanged event occurs. In example when i select a row at first page it gets the field values that i want. But when i change pageindex GetSelectedField cannot get the field values. It alerts empty text. If i select a
  • ASPxGridView 查找控件(Checkbox)并检查它是否被选中(ASPxGridView Find control (Checkbox) and Check if it is checked or not)
    问题 我有一个嵌套在详细网格中的复选框(您可以在下面看到)。 如何在更新点击时找到它并检查是否选中? 我正在使用 DevExpress GridView <dxwgv:GridViewDataCheckColumn Visible="false" VisibleIndex="14"> <EditFormSettings Visible="True" /> <EditItemTemplate> <dxe:ASPxCheckBox ID="ASPxCheckBox1" Text="" runat="server"> </dxe:ASPxCheckBox> </EditItemTemplate> </dxwgv:GridViewDataCheckColumn> 回答1 Protected Sub grid_RowInserting(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxDataInsertingEventArgs) Handles grdProyectos.RowInserting Dim grid As ASPxGridView = (TryCast(sender, ASPxGridView)) Dim chk As CheckBox= grid.FindEditRowCellTemplateControl
  • ASPxGridView、模板和评估(ASPxGridView, ITemplate, and Eval)
    问题 如何在C# 中为 AXPxGridViewDataTextColumn 创建模板而无需任何标记并使用 Eval 来显示 DataItem 值? - 我遇到的问题是字符串 "<%#Eval("dataTableField1")%>" 出现在 GridView 中的每一行而不是适当的值。 这是我尝试的一个例子: public override void DataBind() { ... GridViewDataTextColumn myCol = new GridViewDataTextColumn(); myCol.Caption = "col1"; myCol.FieldName = "dataTableField1"; myCol.DataItemTemplate = new ColumnDataItemTemplate(); theGridView.Columns.Clear(); theGridView.Columns.Add(myCol); theGridView.DataSource = AdjustDataSource(); theGridView.DataBind(); ... } public class ColumnDataItemTemplate : ITemplate { public void InstantiateIn(Control
  • 在 ASPxGridView 中查找复选框控件(Find checkbox control in ASPxGridView)
    问题 我有一个 AspxGridView,它在 gridViewDatacheckColumn 中有一个复选框 dataitemTemplate。 现在我想找到每一行的控件并在运行时取消选中/选中它们。 这是我的 ASPxGridView 代码: <dx:ASPxGridView ID="RadGrid2" runat="server" AutoGenerateColumns="False" ClientInstanceName="grid" KeyFieldName="StoreID" SettingsPager-Mode="ShowAllRecords" Width ="50%"> <Settings ShowVerticalScrollBar="true" /> <Columns> <dx:GridViewDataCheckColumn Caption="#" VisibleIndex="0" Width ="25%"> <DataItemTemplate> <dx:ASPxCheckBox ID="CheckBox1" runat="server"> </dx:ASPxCheckBox> </DataItemTemplate> </dx:GridViewDataCheckColumn> <dx:GridViewDataTextColumn FieldName="STORE
  • 如何获取所选行 Devexpress GridView 的字段值?(How to get field value of selected Row Devexpress GridView?)
    问题 我使用 DevexpressGridView 来显示所有TOPIC (id,title,content) <dx:ASPxGridView ID="gv" runat="server" OnSelectionChanged="gv_SelectionChanged" > 我有 grid_SelectionChanged 事件: protected void gv_SelectionChanged(object sender, EventArgs e) { int id= selected row...???; //how can I get the value of selected row string sql = "select * from TOPIC where idTOPIC="+id; DataTable topic = l.EXECUTEQUERYSQL(sql); TextBox1.Text = topic.Rows[0][1].ToString(); } ... gv.SelectedRow似乎不存在gv.SelectedRow方法。 按照建议,我尝试过FocusedRowIndex方法,但我真的不知道获取所选行值的正确语法。 帮助!!! 回答1 更改选择与更改焦点行不同。 有关两者之间的区别,请参阅 Selection 的文档。 您可以使用 gv
  • ASPxGridView, ITemplate, and Eval
    How can I create a template in c# for an AXPxGridViewDataTextColumn without any markup and with using Eval to display the DataItem value? -The problem that I am having is that the string "<%#Eval("dataTableField1")%>" shows up in the GridView for every row instead of the appropriate values. Here is an example of my attempt: public override void DataBind() { ... GridViewDataTextColumn myCol = new GridViewDataTextColumn(); myCol.Caption = "col1"; myCol.FieldName = "dataTableField1"; myCol.DataItemTemplate = new ColumnDataItemTemplate(); theGridView.Columns.Clear(); theGridView.Columns.Add(myCol)
  • Calculating a ASPxGridview Column in DevExpress
    I have a ASPxGridview (Normally 21 column but i just want process 4 column). Every column has a decimal value. MV_EDDIE column is empty. What i want is, calculating programmaticly ,MV_EDDIE columns is RISK_EUR - (IPOTEK + MV_BERND) only in GroupSummary and TotalSummary. For example; If RISK_EUR = 100 IPOTEK = 40 MV_BERND = 50 Then MV_EDDIE column should be 100 - (40 + 50) = 10 How can i do that? NOTE: I have a Sql like this SELECT A.HESAP_NO, A.TEKLIF_NO1 || '/' || A.TEKLIF_NO2 AS TEKLIF, A.MUS_K_ISIM, A.RISK, (CASE WHEN A.DOVIZ_KOD = 21 THEN 'EUR' WHEN A.DOVIZ_KOD = 2 THEN 'USD' WHEN A.DOVIZ
  • devexpress 行删除事件(devexpress row deleting event)
    问题 Deletebutton 不会引发 OnRowDeleting 事件 我在运行时创建了 devexpress gridview,它运行良好,直到单击删除按钮,当我单击它时,它不起作用。在调试时它不会触发“rowdeleting”。 我能做什么? dovizgrd.Width = Unit.Percentage(50); dovizgrd.EnableCallBacks = false; dovizgrd.Settings.ShowFooter = false; dovizgrd.Settings.ShowColumnHeaders = false; dovizgrd.Settings.ShowFilterBar = GridViewStatusBarMode.Hidden; dovizgrd.SettingsPager.Visible = true; dovizgrd.SettingsPager.Mode = GridViewPagerMode.ShowPager; dovizgrd.Styles.Header.Wrap = DevExpress.Utils.DefaultBoolean.True; dovizgrd.SettingsPager.PageSize = 10; DevExpress.Web.ASPxGridView.GridViewCommandColumn
  • 带有 ObjectDatasource UpdateMethod 的 GridView(GridView with ObjectDatasource UpdateMethod)
    问题 我有一个包含ASPxGridView和ObjectDataSource的 ASP.NET WebForms 页面: <dx:ASPxGridView ID="gvEmployees" runat="server" AutoGenerateColumns="False" DataSourceID="objDsEmployees" KeyFieldName="EmployeeId"> <Columns> <dx:GridViewCommandColumn VisibleIndex="0"> <EditButton Visible="True" /> </dx:GridViewCommandColumn> <dx:GridViewDataTextColumn FieldName="EmployeeId" VisibleIndex="1" /> <dx:GridViewDataTextColumn FieldName="Name" VisibleIndex="2" /> <dx:GridViewDataTextColumn FieldName="Email" VisibleIndex="3" /> <dx:GridViewDataTextColumn FieldName="Telephone" VisibleIndex="5" /> </Columns> </dx
  • ASPxGridView Find control (Checkbox) and Check if it is checked or not
    I have a checkbox (you can see below) nested in detailed grid. How can I find it on updating click and check if checked or not? I'm using DevExpress GridView <dxwgv:GridViewDataCheckColumn Visible="false" VisibleIndex="14"> <EditFormSettings Visible="True" /> <EditItemTemplate> <dxe:ASPxCheckBox ID="ASPxCheckBox1" Text="" runat="server"> </dxe:ASPxCheckBox> </EditItemTemplate> </dxwgv:GridViewDataCheckColumn>
  • devexpress row deleting event
    Deletebutton doesn't raise OnRowDeleting event i created devexpress gridview on runtime it s working good until click the delete button ,when i click it ,it doesn't work .on debug it doesnt fire "rowdeleting". What can i do? dovizgrd.Width = Unit.Percentage(50); dovizgrd.EnableCallBacks = false; dovizgrd.Settings.ShowFooter = false; dovizgrd.Settings.ShowColumnHeaders = false; dovizgrd.Settings.ShowFilterBar = GridViewStatusBarMode.Hidden; dovizgrd.SettingsPager.Visible = true; dovizgrd.SettingsPager.Mode = GridViewPagerMode.ShowPager; dovizgrd.Styles.Header.Wrap = DevExpress.Utils
  • GridView with ObjectDatasource UpdateMethod
    I have an ASP.NET WebForms page containing an ASPxGridView and an ObjectDataSource: <dx:ASPxGridView ID="gvEmployees" runat="server" AutoGenerateColumns="False" DataSourceID="objDsEmployees" KeyFieldName="EmployeeId"> <Columns> <dx:GridViewCommandColumn VisibleIndex="0"> <EditButton Visible="True" /> </dx:GridViewCommandColumn> <dx:GridViewDataTextColumn FieldName="EmployeeId" VisibleIndex="1" /> <dx:GridViewDataTextColumn FieldName="Name" VisibleIndex="2" /> <dx:GridViewDataTextColumn FieldName="Email" VisibleIndex="3" /> <dx:GridViewDataTextColumn FieldName="Telephone" VisibleIndex="5" /> <
  • How to programmatically reach any AspxControl inside an AspXGridView's EditItemTemplate
    Its very simple and i feel myself as an idiot :( I newly started to using DevX Controls. Its documentation and sample projects are SUCKS! My problem is: I have an ASPxGridView on my aspx page: <dx:ASPxGridView ID="dxdgMyGrid" runat="server" AutoGenerateColumns="False" OnStartRowEditing="DxGridStartRowEditing"> <SettingsEditing Mode="PopupEditForm" PopupEditFormHeight="200px" PopupEditFormWidth="500px" EditFormColumnCount="2" PopupEditFormHorizontalAlign="Center" PopupEditFormVerticalAlign="Middle" PopupEditFormModal="true" /> <Columns> <dx:GridViewDataTextColumn FieldName="MyField1"