Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
Checkbox in WebDataGrid
posted

I have a boolean value in a datatable that i bind to a datagrid from the codebehind. But instead of a checkbox the webDataGrid displays "true" or "false" and that column is editable like a string value.

 

Here is some code that i'm using (_sestevalniDT is a DataTable and SestevalniStevec is a WebDataGrid):

_sestevalniDT = new DataTable();

_sestevalniDT.Columns.Add(new DataColumn("Naziv", typeof(string)));

_sestevalniDT.Columns.Add(new DataColumn("Popravek", typeof(bool)));

...

SestevalniStevec.DataSource = _sestevalniDT;

SestevalniStevec.DataBind();

 

and this is from my aspx:

<ig:WebDataGrid ID="SestevalniStevec" runat="server" StyleSetName="Appletini" Width="640"
                                                Height="480" DataKeyFields="Naziv">
                                                <Behaviors>
                                                    <ig:ColumnResizing Enabled="true">
                                                        <ColumnSettings>
                                                            <ig:ColumnResizeSetting EnableResize="true" />
                                                        </ColumnSettings>
                                                    </ig:ColumnResizing>
                                                    <ig:EditingCore>
                                                        <Behaviors>
                                                            <ig:CellEditing Enabled="true" EditModeActions-MouseClick="Single">
                                                                <CellEditingClientEvents EnteringEditMode="svoEnteringEditMode" />
                                                            </ig:CellEditing>
                                                        </Behaviors>
                                                    </ig:EditingCore>
                                                </Behaviors>
                                            </ig:WebDataGrid>

 

What should i add in order for the bool value to display as a checkbox?

 

Thanks for your help.

Parents Reply
  • 180
    posted in reply to Jernej

    I found an article about WebDataGrid editor providers and i thought i could make one with a checkbox. But this seems to be quite hard as well, this is the code i have so far:

    namespace wCSRE.BLL
    {
        public class CheckBoxProvider : EditorProvider<CheckBox>
        {
            protected override bool CanEditType(Type t)
            {
                string name = t.FullName;
                if (t.Name == "Boolean" || t.Name == "bool") 
                    return true; 
                return false; 
            }
            protected override string ClientObjectClassName
            {
                get
                {
                    return "Infragistics.Web.UI.EditorProvider";
                    //return "wCSRE.BLL.CheckBoxProvider";
                }
            }
        }
    }

    But when i try to use it, i get "Specified method is not supported" from javascript.

    Anyway i think an editorprovider can't be the right solution for me either, common sense suggests that there MUST be a way to turn on checkboxes for boolean values without this many complications. In fact it is strange that the WebDataGrid doesn't display the boolean value as a checkbox in the first place.

     

    admin: don't mark this one as an answer either please

Children