Forum


06:11

28/10/2009

Hello,
I am using Jqgrid ASP.net version. What I am doing is I want to show checkbox on my jqgrid. I did it with the snipped code given below. But I am getting some strange output.
I am getting "True","false" values on grid instead of actual checkbox (which is either in checked/unchecked state). But when I go for editing the corrosponding row, I am getting checkbox.
My code snippet:
<cc1:JQGrid ID="JQGrid1" runat="server" Width="700px" DataSourceID="Datasource"
OnCellBinding="JQGrid1_CellBinding" OnRowEditing="JQGrid1_RowEditing" ShowToolBar="true">
<Columns>
<cc1:JQGridColumn DataField="ID" PrimaryKey="true" Visible="false" />
<cc1:JQGridColumn DataField="Name" Editable="true"
TextAlign="Center" Width="50" />
<cc1:JQGridColumn DataField="IsActive" EditType="CheckBox" Editable="true" TextAlign="Center" />
</Columns>
<ToolBarSettings ShowEditButton="true" ShowAddButton="true" ShowDeleteButton="true" />
</cc1:JQGrid>
Help is appreciated.
Thanks.
Suraj
11:58

Moderators
08/10/2009

Hello,
EditType = CheckBox (and EditType in general) is only used in edit mode, e.g. in inline or edit dialog editing. In standard read only mode, the value of the actual field is displayed (true / false in your case).
If you wish to modify that, you can hook the CellBinding event, check for that column and modify the default "True / False" formatting to anything you wish HTML-wise, e.g.
protected void JQGrid1_CellBinding(object sender, Trirand.Web.UI.WebControls.JQGridCellBindEventArgs e)
{
if (e.ColumnIndex == 4)
{
bool value = Convert.ToBoolean(e.CellHtml);
if (value)
{
e.CellHtml = "<input type='checkbox' disabled='true' checked='true'>";
}
else
{
e.CellHtml = "<input type='checkbox' disabled='true' checked='false'>";
}
}
}
Trirand ASP.NET WebForms & MVC components based on jQuery & ThemeRoller
Most Users Ever Online: 715
Currently Online:
70 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66