mercredi 21 mars 2018

Always get False in checkbox value in kendo grid.

My kendo Code is:

<div id="plannedValueGrids" class="box-body no-padding" style="margin-top: 5px;"> @(Html.Kendo().Grid(Model.PlannedValues) // Bind the grid to the Model property of the view .Name("plannedValueGrid")

                                                         .Columns(columns =>
                                                         {
                                                             columns.Bound(p => p.MetricID).Hidden();
                                                             columns.Bound(p => p.IsHistoryUpdateIfPlannedValueChanged).Title("IsHistoryUpdateIfPlannedValueChanged").Width(100).HtmlAttributes(new { style = "text-align: center;" }).HeaderHtmlAttributes(new { @title = "IsHistoryUpdateIfPlannedValueChanged", style = "text-align: center; font-weight: bold;" }).ClientTemplate("<input type='checkbox' value='' checked='#=IsHistoryUpdateIfPlannedValueChanged#' />");

                                                             //columns.Bound(p => p.IsLinear).Title(Resources.Performance.IsLinear).Width(60).Sortable(false);
                                                             columns.Bound(p => p.PlannedJumpOffValue).Hidden().Title(Resources.Performance.PlannedJumpOffValue).HeaderHtmlAttributes(new { @title = Resources.Performance.PlannedJumpOffValue, style = "text-align: center; font-weight: bold;", @class = "jumpOffA" }).HtmlAttributes(new { style = "text-align: right;" }).ClientTemplate("#= kendo.format(\"{0:0.0000}\", (PlannedJumpOffValue != null)? PlannedJumpOffValue:0 )#");
                                                             columns.Bound(p => p.PlannedJumpOffRaw1).Hidden().Title(Resources.Performance.PlannedjumpOffB).HeaderHtmlAttributes(new { @title = Resources.Performance.PlannedjumpOffB, style = "text-align: center; font-weight: bold;" }).HtmlAttributes(new { style = "text-align: right;" }).ClientTemplate("#= kendo.format(\"{0:0.0000}\", (PlannedJumpOffRaw1 != null)? PlannedJumpOffRaw1:0 )#");
                                                             columns.Bound(p => p.PlannedTarget).Title(Resources.Performance.Planned).HeaderHtmlAttributes(new { @title = Resources.Performance.Planned, style = "text-align: center; font-weight: bold;", @class = "plannedA" }).HtmlAttributes(new { style = "text-align: right;" }).ClientTemplate("#= kendo.format(\"{0:0.0000}\", (PlannedTarget != null)? PlannedTarget:0 )#");
                                                             columns.Bound(p => p.PlannedRaw1).Title(Resources.Performance.PlannedB).HeaderHtmlAttributes(new { @title = Resources.Performance.PlannedB, style = "text-align: center; font-weight: bold;" }).HtmlAttributes(new { style = "text-align: right;" }).ClientTemplate("#= kendo.format(\"{0:0.0000}\", (PlannedRaw1 != null)? PlannedRaw1:0 )#");
                                                             columns.Bound(p => p.PlannedTargetStartDate).Title(Resources.Common.StartDate).Width(100).HtmlAttributes(new { style = "text-align: center;" }).HeaderHtmlAttributes(new { @title = Resources.Common.StartDate, style = "text-align: center; font-weight: bold;" });
                                                             columns.Bound(p => p.PlannedEndDate).Title(Resources.Common.EndDate).Width(100).HtmlAttributes(new { style = "text-align: center;" }).HeaderHtmlAttributes(new { @title = Resources.Common.EndDate, style = "text-align: center; font-weight: bold;" });
                                                             //columns.Bound(p => p.LinearDuration).Title(Resources.Performance.LinearDuration).Column.Hidden = true;
                                                             //columns.ForeignKey(p => p.LinearDurationUnitID, Model.MetricDurationUnits, "UnitID", "Unit").Title(Resources.Performance.Unit).Width(100).Column.Hidden = true;
                                                             //columns.Command(command => command.Destroy()).Title(Resources.Common.Action).Width(60).HeaderHtmlAttributes(new { @title = Resources.Common.Action, style = "text-align: center; font-weight: bold;" }).HtmlAttributes(new { style = "text-align: center;" });
                                                             //columns.Bound(p => p.IsHistoryUpdateIfPlannedValueChanged).Title("IsHistoryUpdateIfPlannedValueChanged").Width(100).HtmlAttributes(new { style = "text-align: center;" }).HeaderHtmlAttributes(new { @title = "IsHistoryUpdateIfPlannedValueChanged", style = "text-align: center; font-weight: bold;" }).ClientTemplate("<input type='checkbox' class='checkboxIsHistoryUpdateIfPlannedValueChanged'/>");



                                                             columns.Command(command => command.Custom("Delete").Click("kRemovePlanned")).Title(Resources.Common.Action).Width(50).HeaderHtmlAttributes(new { @title = Resources.Common.Action, style = "text-align: center; font-weight: bold;" }).HtmlAttributes(new { style = "text-align: center;" });
                                                         })
                                                           .ToolBar(toolBar =>
                                                           {
                                                               toolBar.Template("<a id='kAddPlanned' class='k-grid-add' href='#'><i class='fa fa-plus-square'></i>&nbsp;" + Resources.Performance.AddPlannedValues + "</a>");
                                                               toolBar.Save().HtmlAttributes(new { @style = "display:none" }); // The "save" command saves the changed data items
                                                           })
                                                                           .Editable(editable => { editable.Mode(GridEditMode.InCell); })// Use in-cell editing mode

                                                          .DataSource(dataSource => dataSource.Ajax()
                                                                         .Batch(true) // Enable batch updates
                                                                          .Model(model =>
                                                                          {
                                                                              model.Id(p => p.MetricPlannedId);
                                                                              //model.Field(p => p.LinearDurationUnitID).DefaultValue(0);
                                                                              model.Field(p => p.MetricID).DefaultValue(0);

                                                                          })
                                                              .ServerOperation(false)

                                                             // Configure CRUD -->
                                                             .Update(update => update.Action("Update", "Home"))


                                                            // <-- Configure CRUD
                                                            )
                                                            .Events(e =>
                                                            {
                                                                e.DataBound("kDataBoundPlanned");
                                                                //e.Remove("kRemovePlanned");
                                                                e.Save("kSavePlanned");
                                                                e.Edit("kEditPlanned");
                                                            })
                                                             .Scrollable(src => src.Height(120)).Navigatable().Sortable()
                            )


                            @Html.HiddenFor(m => m.PlannedValuesJSON, new { @id = "hdnPlannedValues" })
                            @Html.HiddenFor(m => m.PlannedVaueJSONBeforeEdit, new { @id = "hdnPlannedValuesBeforeEdit" })
                            @Html.HiddenFor(m => m.flag, new { @id = "hdnFlag" })
                        </div>`

And this is how i am getting the values

var plannedValues = kendo.stringify($("#plannedValueGrid").data("kendoGrid").dataSource.view()); //var plannedValues = $('#plannedValueGrid').data('kendoGrid').dataSource.data(); $("#hdnPlannedValues").val(plannedValues);

i have added new checkbox, and i always getting false in this. even i have checked it.

i am not able to get what i am doing wrong. please guide me




Aucun commentaire:

Enregistrer un commentaire