I have custom 'Add New' button in grid. On click of that button, it should pop up a new window and the value that is selcted is then inserted into the grid.. I have that working, but after inserting a new row, the built in 'Save Changes' button is not working..
Here is my code
@(Html.Telerik().Grid<
AccountingProgram>(Model.AccountingPrograms)
.Name("AccountingProgramsGrid")
.DataKeys(keys => keys.Add(item => item.AcProgramId))
.EnableCustomBinding(true)
.Editable(editing => editing.Mode(GridEditMode.InCell))
.Columns(columns =>
{
columns.Bound(pgm => pgm.GroupId).Title("Accounting Program Id");
columns.Bound(pgm => pgm.EvaluationTemplateName).Title("Evaluation Template Name").ReadOnly();
columns.Bound(pgm => pgm.TypeOfEntityDesc).Title("Type Of Entity").ReadOnly();
columns.Command(commands => commands.Delete()).Title(
"Delete");
})
.Scrollable(scrl => scrl.Height("auto"))
.Filterable(filtering => filtering.Enabled(false))
.Groupable(grouping => grouping.Enabled(false))
.DataBinding(dataBinding => dataBinding.Ajax().Update("_SaveBatchEditing", "SPEPrograms"))
.ToolBar(commands =>{
commands.Custom().Text(
"Add New").HtmlAttributes(new {@onclick="ClickEvent();return false;"});
//commands.Insert();
commands.SubmitChanges();
}))Here is the javascript code
function ClickEvent() {
$.ajax({url: "/Search/AcctPgmSearch",
type: "Get",
success: function (data) {
var features = "height=700,width=800,scrollTo,resizable=1,scrollbars=1,location=0";
newwindow = window.open(
'/Search/AcctPgmSearch', 'Popup', features);}
});
}
function AddToGrid(col) {var newItem1 =col; //get new val 1
var lastGridRow = $("#AccountingProgramsGrid tbody tr:last"); //Get the current last row in the grid
var gridItems = $("#AccountingProgramsGrid tbody"); //Get the grid row containervar lastIsAlternateRow = lastGridRow.hasClass("t-alt"); //see if the current last row has the alternating
var rowClass = "";
if (!lastIsAlternateRow) //if the last row is not the alternate style, then the new one needs to have it
rowClass = "t-alt";
gridItems.append(
"<tr class='" + rowClass + "'><td>" + newItem1 + "</td></tr>"); //append the new row to the grid row}