- Home
- Forum
- ASP.NET MVC (Classic)
- input checbox in grid
input checbox in grid
HI
I would like to add a column with an input type "checkbox" to the MVC grid. Is this possible?
THX in advance.
I would like to add a column with an input type "checkbox" to the MVC grid. Is this possible?
THX in advance.
SIGN IN To post a reply.
3 Replies
BM
Balaji M
Syncfusion Team
October 1, 2009 10:51 PM UTC
Hi Pawel,
Thank you for your interest in Syncfusion products.
We suggest you to use the Format option inside QuerycellInfo, in order to achieve this Checkbox inside Grid.
Please refer the following code snippet to achieve this.
public ActionResult Index()
{
GridPropertiesModel model = new GridPropertiesModel
{
DataSource=context.Students.Skip(0).Take(10),
Caption="Student List",
PrimaryKeyColumns={"ID"}
};
ViewData["GridModel"] = model;
model.QueryCellInfo += new GridTableCellStyleInfoEventHandler(model_QueryCellInfo);
return View();
}
void model_QueryCellInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
{
if (e.TableCellIdentity.Column.MappingName == "Result")
{
if ((bool)e.Style.CellValue)
e.Style.Format = "";
else
e.Style.Format = "";
e.Handled = true;
}
}
}
Please refer the sample from the below link.
http://files.syncfusion.com/support/grid_mvc/Incidents/F90441/Mvc_SampleGrid.zip
The Sample illustrates,
1. Result is column contains the boolean value.
2. Inside QueryCellInfo event, Result column in the grid formatted using style.Format property.
Please let me know if you have any concerns.
Regards,
M. Balaji
Thank you for your interest in Syncfusion products.
We suggest you to use the Format option inside QuerycellInfo, in order to achieve this Checkbox inside Grid.
Please refer the following code snippet to achieve this.
public ActionResult Index()
{
GridPropertiesModel model = new GridPropertiesModel
{
DataSource=context.Students.Skip(0).Take(10),
Caption="Student List",
PrimaryKeyColumns={"ID"}
};
ViewData["GridModel"] = model;
model.QueryCellInfo += new GridTableCellStyleInfoEventHandler(model_QueryCellInfo);
return View();
}
void model_QueryCellInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
{
if (e.TableCellIdentity.Column.MappingName == "Result")
{
if ((bool)e.Style.CellValue)
e.Style.Format = "";
else
e.Style.Format = "";
e.Handled = true;
}
}
}
Please refer the sample from the below link.
http://files.syncfusion.com/support/grid_mvc/Incidents/F90441/Mvc_SampleGrid.zip
The Sample illustrates,
1. Result is column contains the boolean value.
2. Inside QueryCellInfo event, Result column in the grid formatted using style.Format property.
Please let me know if you have any concerns.
Regards,
M. Balaji
PS
Pawel Szpytma
October 7, 2009 02:16 PM UTC
Hi,
I used the code recommended by you, but i'm having problems with sorting. When I sort the column, it changes from input type to normal text,
THX in advance.
I used the code recommended by you, but i'm having problems with sorting. When I sort the column, it changes from input type to normal text,
THX in advance.
BM
Balaji M
Syncfusion Team
October 8, 2009 05:06 AM UTC
Hi Pawel,
Thank you for your interest in Syncfusion product.
This is default behaviour of MVC Grid. We suggest you to bind QueryCellInfo event in ActionResult,in order to get the format at all pages.
Refer the below code snippet, which illustrates this.
Please refer the updated sample from the below link.
http://files.syncfusion.com/support/grid_mvc/Incidents/F90441/Mvc_SampleGrid1.zip
Please let me know if you have any concerns.
Regards,
M. Balaji.
Thank you for your interest in Syncfusion product.
This is default behaviour of MVC Grid. We suggest you to bind QueryCellInfo event in ActionResult,in order to get the format at all pages.
Refer the below code snippet, which illustrates this.
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SortingAction(PagingParams args)
{
GridHtmlActionResult result = new GridHtmlActionResult();
result.GridModel.DataSource = context.Students.Skip(0).Take(10);
result.GridModel.QueryCellInfo += new GridTableCellStyleInfoEventHandler(model_QueryCellInfo);
return result;
}Please refer the updated sample from the below link.
http://files.syncfusion.com/support/grid_mvc/Incidents/F90441/Mvc_SampleGrid1.zip
Please let me know if you have any concerns.
Regards,
M. Balaji.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
PS Pawel Szpytma
- Oct 1, 2009 12:04 PM UTC
- Oct 8, 2009 05:06 AM UTC