C# MVC Inline editing of local datasource - issue when adding command button

1 Answer 129 Views
Editor Grid
Sean
Top achievements
Rank 1
Sean asked on 26 May 2021, 09:35 AM


@using EconExcelExtender.Classes

@model List<PocoAttributeDetail>

@{
    var modelName = ViewBag.ModelName;
    var companySite = ViewBag.CompanySite;
    var inUse = ViewBag.InUse;
    int hasBeenDownloaded = (int)ViewBag.HasBeenDownloaded;
}

<div id="mdlattributeMaintenance" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-xl" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Attribute Maintenance</h5>
            </div>
            <div id="attributeMaintenanceBody" class="modal-body">

            </div>
        </div>
    </div>
</div>

@if (hasBeenDownloaded == (int)Enums.AttributeOptionDownloadStatus.InAttributesAndOptions)
{

    <div class="row mt-2">
        <div class="col-12 text-center">
            <h6>Attributes for Model @modelName only exist in the Attribute And Options Table</h6>
            <h6>They must be downloaded before adding new records, or editing existing records can take place.</h6>
        </div>
        <div class="col-12 text-center">
            <button type="button" id="btnDownloadAttributes" onclick="" data-text="Download Attributes" class="btn btn-danger form-control btnDownloadAttributes">Download Attributes</button>
        </div>
    </div>


}

@if (hasBeenDownloaded == (int)Enums.AttributeOptionDownloadStatus.None)
{

    <div class="row mt-2">
        <div class="col-12 text-center">
            <h6>There are no attributes for Model @modelName found on the database</h6>
            <h6>They must be entered using this form.</h6>
        </div>
    </div>

}


@if (Model != null)
{

    <div class="mt-2">
        @(Html.Kendo().Grid(Model)
            .Name("grid")
            .TableHtmlAttributes(new {@style="font-size:smaller"})
            .Columns(columns => {


                columns.Bound(p => p.AttributeDetailID).Title("Attribute ID").Width(105);
                columns.Bound(p => p.AttributeCode).Title("Attribute Code").Width(105);
                columns.Bound(p => p.AttributeName).Title("Attribute Name").Width(150);
                columns.Bound(p => p.InputOutput).Title("Input/Output").Width(105);
                columns.Bound(p => p.Type).Title("Type").Width(105);
                columns.Bound(p => p.IsRange).Title("Is Range").Width(80)
                    .ClientTemplate("#= IsRange ? 'Yes' : 'No' #");
                columns.Bound(p => p.HasLabels).Title("Has Range").Width(80)
                    .ClientTemplate("#= HasLabels ? 'Yes' : 'No' #");
                columns.Bound(p => p.InUse).Title("In Use").Width(80)
                    .ClientTemplate("#= InUse ? 'Yes' : 'No' #");
                
                 columns.Command(commands =>
 {
 commands.Edit();
 commands.Destroy();
 });


            })
                .HtmlAttributes(new { style = "height: 550px;" })

                .Sortable()
    .Scrollable(scr=>scr.Height(430))
    .Filterable()
    .Pageable()

    //.Editable(editable => editable.Mode(GridEditMode.PopUp))


    .DataSource(ds => {
        ds.Ajax()
        .Model(model => model.Id(p => p.AttributeDetailID))

     .ServerOperation(false);


        ;



    })
    )
    </div>

}

@using (Ajax.BeginForm("MaintainAttribute", "AttributesAndOptions", null, new AjaxOptions
{
    UpdateTargetId = "attributeMaintenanceBody",
    InsertionMode = InsertionMode.Replace,
    OnComplete = "$('#mdlattributeMaintenance').modal('show');  ShowSpinner(null, '', 'hide'); ",
    HttpMethod = "Post"

}, new { @id = "frmMaintModelAttributes" }))
{

    <input type="hidden" id="itemModel" name="ModelName" value="@modelName" />
    <input type="hidden" id="itemID" name="ItemID" />
}

@using (Ajax.BeginForm("DownloadAttributes", "AttributesAndOptions", null, new AjaxOptions
{
    UpdateTargetId = "maintenancediv",
    InsertionMode = InsertionMode.Replace,
    OnComplete = "SetUpTable('#tblDisplay');ShowSpinner(null, '', 'hide'); ",
    HttpMethod = "Post"

}, new { @id = "frmDownloadAttributes" }))
{

    <input type="hidden" id="optionModel" name="ModelName" value="@modelName" />
    <input type="hidden" id="optionCompany" name="CompanySite" value="@companySite" />

}

Hi,

I am trying to do inline editing on a local datasource provided from a controller source. 

When I add the command button I get the following error:

System.InvalidOperationException: 'The parameter conversion from type 'System.String' to type 'System.Boolean' failed. See the inner exception for more information.'

This is the error message: 		"-1 is not a valid value for Boolean."


I'm wondering what I am doing wrong.

 

Thanks

 

Sean

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 31 May 2021, 09:25 AM

Hello Sean,

Thank you for the code snippets and details provided.

I am now trying to reproduce the described behavior.

The fastest route to getting you up and running is if you could provide a runnable, isolated, sample project. Examining this project will let us replicate the issue locally and further troubleshoot it.

Looking forward to hearing back from you.

 

Kind Regards,
Anton Mironov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Editor Grid
Asked by
Sean
Top achievements
Rank 1
Answers by
Anton Mironov
Telerik team
Share this question
or