开发者

Implementing a Red Cross -Check Box in the Selection Column of the ASPxGridView or general GridView

I am currently using DevExpress ASPxGridView and want the selection check box to show a redcross image on selection or empty when unselected. Is there any javascript library to do such a thing. If so can you provide me an example.

Pelase make sure that your solution would not hinder me to开发者_如何学JAVA perform Callbacks on SelectionChanged Event.

Note: You may give me solutions for general GridView or ASPxGridView.


Ok Guys, I think this is the best possible way to do it.

You can toggele the image of the Select command Button.

<dx:ASPxGridView ID="ChildGridView" runat="server" KeyFieldName="Log_ID" OnCommandButtonInitialize="ChildGrid_CommandButtonInitialize" OnCustomCallback="ChildGridView_CustomCallback" Width="100%" OnHtmlRowPrepared="ChildGridView_HtmlRowPrepared">

                            <Settings showcolumnheaders="false" gridlines="None"  ShowStatusBar="Hidden" ShowPreview="true" ShowTitlePanel="false"  />
                            <SettingsPager ShowEmptyDataRows="false" Visible="false"></SettingsPager>
                            <Paddings Padding="0px" />
                            <Border BorderWidth="0px" BorderColor="#cccccc"  BorderStyle="None" />
                            <settingsbehavior  />
                            <clientsideevents selectionchanged="function(s,e){                                                                                                                                                                                                
                                                                s.PerformCallback(e.visibleIndex);
                            }" />

                            <Columns>                          
                            <dx:GridViewCommandColumn ButtonType="Image" ShowSelectCheckbox="false" Name="IsChecked">                              
                             <SelectButton  Visible="true" >                               
                               </SelectButton>
                            </dx:GridViewCommandColumn>

                            <dx:GridViewDataTextColumn FieldName="Log_ID" Caption="Log_ID" Visible="false" />
                            <dx:GridViewDataTextColumn FieldName="Message" Caption="Messages" />
                            <dx:GridViewDataTextColumn FieldName="IsRuleBad" Caption="IsRuleBad" Visible="false" />
                            <dx:GridViewDataTextColumn FieldName="Pending_MainTrade_ID" Caption="MainTradeId" Visible="false" />
                            </Columns>
                        </dx:ASPxGridView>

Code Behind:

 protected void ChildGrid_CommandButtonInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCommandButtonEventArgs e)
    {
        string appPath = HttpContext.Current.Request.ApplicationPath;

        ASPxGridView childGrid = sender as ASPxGridView;

        if (e.ButtonType != DevExpress.Web.ASPxGridView.ColumnCommandButtonType.Select) return;
        bool isRowSelected = childGrid.Selection.IsRowSelected(e.VisibleIndex);
        if (isRowSelected)
        {
            e.Image.Url = appPath + "/images/votedown.png";

        }
        else
        {
            e.Image.Url = appPath + "/images/voteup.png";
        }

    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜