This is a migrated thread and some comments may be shown as answers.

[Solved] MVC Grid custom formatting not working on Ajax Update()

1 Answer 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ryan
Top achievements
Rank 1
Ryan asked on 14 Jul 2011, 03:40 PM

IF anyone can help me with this it would be greatly appreciated.

My situation is as follows;
My grid, has some custom formattting applied to it. The inital select works fine, but when a do an Ajax Update(), the formatting gets completely messed up(The colours are all red, this this example). The only way to reshow the grid with the correct formatted colours is to Reload the entire page.

 

@(Html.Telerik().Grid(Model)

.Name(

 

"PageMasters")

 

.DataKeys(keys =>

{

keys.Add(p => p.PAGENO);

})

.DataBinding(dataBinding =>

{

dataBinding.Ajax()

.Select(

 

"_SelectAjaxEditing", "PageMaster")

 

.Insert(

 

"_InsertAjaxEditing", "PageMaster")

 

.Update(

 

"_UpdateAjaxEditing", "PageMaster")

 

.Delete(

 

"_DeleteAjaxEditing", "PageMaster");

 

})

.Columns(columns =>

{

columns.Bound(p => p.PAGENO).Width(210);

columns.Bound(p => p.DESCRIPTION).Width(130);

columns.Bound(p => p.MAXVARIABLES);

columns.Bound(p => p.CAPTUREFLG)

.ClientTemplate(

 

"<input type='checkbox' disabled='disabled' name='CAPTUREFLG' <#= CAPTUREFLG? checked='checked' : '' #> />");

 

columns.Command(commands =>

{

commands.Edit().ButtonType(type);

commands.Delete().ButtonType(type);

}).Width(180).Title(

 

"Commands");

 

})

.CellAction(cell =>

{

 

 

if (cell.Column.Member == "MAXVARIABLES")

 

{

 

 

if (cell.DataItem.MAXVARIABLES < 10)

 

{

cell.HtmlAttributes[

 

"style"] = "background: Green;";

 

}

 

 

else if (cell.DataItem.MAXVARIABLES > 10 && cell.DataItem.MAXVARIABLES < 20)

 

{

cell.HtmlAttributes[

 

"style"] = "background: Yellow;";

 

}

 

 

else if (cell.DataItem.MAXVARIABLES > 20 && cell.DataItem.MAXVARIABLES < 30)

 

{

cell.HtmlAttributes[

 

"style"] = "background: Orange;";

 

}

 

 

else if (cell.DataItem.MAXVARIABLES > 30)

 

{

cell.HtmlAttributes[

 

"style"] = "background: Red;";

 

}

}

})

.Pageable(page => page.PageSize(10))

.Scrollable()

.Sortable()

)

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 14 Jul 2011, 04:04 PM
Hello Ryan,

 RowAction and CellAction are executed server side. This means that your formatting will be applied only during server binding. For ajax binding you can hook to the OnRowDataBound event.

All the best,
Atanas Korchev
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or