Hi,
I have a grid with 4 grid bound columns and 1 grid numeric column and the numeric column is in inplace edit mode and there are two buttons - Save & Cancel. When search button clicks, grid will be populated with data.
Here is my requirement.
When user modifies data in the numeric column and clicks on Save button, I have written a validate function to validate the modified data and if the modified data is not as per the rules then those cells should be displayed in red with the modified data so that user can check what was wrong with the data.
Can you please tell me how to achieve this ?
I also have NeedDataSource method & Grid_Prerender method. please see the below code.
I have a grid with 4 grid bound columns and 1 grid numeric column and the numeric column is in inplace edit mode and there are two buttons - Save & Cancel. When search button clicks, grid will be populated with data.
Here is my requirement.
When user modifies data in the numeric column and clicks on Save button, I have written a validate function to validate the modified data and if the modified data is not as per the rules then those cells should be displayed in red with the modified data so that user can check what was wrong with the data.
Can you please tell me how to achieve this ?
I also have NeedDataSource method & Grid_Prerender method. please see the below code.
protected
void
Page_Init()
{
ConfigureGrid();
}
private
void
ConfigureGrid()
{
try
{
OrderTypeRankingGrid.AddNeedDataSourceEventHandler(NeedDataSource);
OrderTypeRankingGrid.AddGridCommandEventHandler(DataGrid_ItemCommand);
OrderTypeRankingGrid.PreRender +=
new
EventHandler(OrderTypeRankingGrid_PreRender);
OrderTypeRankingGrid.AllowColumnsReorder =
false
;
OrderTypeRankingGrid.GridHeaderText =
"Order Type Ranking"
;
var masterView = OrderTypeRankingGrid.ConfigureMasterTableView(
"vDivisionOrderTypeRanking"
,
new
string
[] {
"DivisionOrderTypeRankId"
,
"CategoryCode"
,
"PurposeCode"
,
"ReasonCode"
,
"ReasonDescription"
});
masterView.AllowFilteringByColumn =
true
;
masterView.AllowSorting =
true
;
masterView.FullEditMode =
true
;
masterView.EditMode = GridEditMode.InPlace;
masterView.EnableShowHideColumns =
true
;
masterView.SetPaging(GridPagerMode.NextPrevAndNumeric);
masterView.GridTableView.ShowHeader =
true
;
masterView.ShowHeader =
true
;
masterView.ShowFooter =
true
;
masterView.ShowHeadersWhenNoRecords =
true
;
masterView.AllowPaging =
true
;
//masterView.PageSize = 50;
masterView.AddNgmCommandButton(NgmButtonType.Save,
"btnSave"
,
null
,
null
,
null
, Unit.Pixel(50));
masterView.AddNgmCommandButton(NgmButtonType.Cancel,
"btnCancel"
,
null
,
null
,
null
, Unit.Pixel(50));
masterView.CommandItemDisplay = GridCommandItemDisplay.Bottom;
if
(!IsPostBack)
//must check for postback; otherwise, columns will be duplicated
{
masterView.AddBoundColumn(
"CategoryCode"
,
"Category Code"
,
"CategoryCode"
,
true
,
false
,
true
, Unit.Percentage(7.0));
masterView.AddBoundColumn(
"PurposeCode"
,
"Purpose Code"
,
"PurposeCode"
,
true
,
false
,
true
, Unit.Percentage(7.0));
masterView.AddBoundColumn(
"ReasonCode"
,
"Reason Code"
,
"ReasonCode"
,
true
,
false
,
true
, Unit.Percentage(7.0));
masterView.AddBoundColumn(
"ReasonDescription"
,
"Reason Description"
,
"ReasonDescription"
,
true
,
false
,
true
, Unit.Percentage(7.0));
masterView.AddNumericColumn(
"OrderTypeRank"
,
"Rank"
,
"OrderTypeRank"
,
false
,
false
,
true
, Unit.Percentage(7.0),
typeof
(
int
),NumericType.Number,
"{0:N0}"
, 10);
}
}
catch
(System.Exception ex)
{
base
.AddException(ex);
}
}
protected
void
OrderTypeRankingGrid_PreRender(
object
sender, EventArgs e)
{
if
(IsPostBack)
{
for
(
int
i = 0; i < OrderTypeRankingGrid.PageCount; i++)
{
OrderTypeRankingGrid.EditIndexes.Add(i);
}
OrderTypeRankingGrid.Rebind();
}
}
protected
void
NeedDataSource(
object
source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
try
{
if
(IsPostBack)
{
if
(!e.IsFromDetailTable && (
this
.productDivision == 1 ||
this
.productDivision == 2))
{
productDivision =
long
.Parse(cboxDivision.SelectedValue.ToString());
IDivisionOrderTypeRankService divisionOrderTypeRankServiceAgent =
null
;
divisionOrderTypeRankServiceAgent = (IDivisionOrderTypeRankService)ContextRegistry.GetContext().GetObject(
"DivisionOrderTypeRankServiceAgent"
);
IList<DivisionOrderTypeRankDTO> divisionOrderTypeRankDTOs = divisionOrderTypeRankServiceAgent.GetDivisionOrderTypeRankByDivision(productDivision);
if
(divisionOrderTypeRankDTOs.Count > 1)
{
var divOrderTypeRankDTOstemp = from b
in
divisionOrderTypeRankDTOs
orderby b.CategoryCode ascending, b.PurposeCode ascending, (b.OrderTypeRank ==
null
?
int
.MaxValue : b.OrderTypeRank) ascending
select b;
OrderTypeRankingGrid.DataSource = divOrderTypeRankDTOstemp;
}
else
{
base
.AddWarning(
"There are no records to display"
);
}
}
}
}
catch
(System.Exception ex)
{
base
.AddException(ex);
}
}