CRUD functionality in GRID Taghelpers

2 posts, 0 answers
  1. Maxime
    Maxime avatar
    2 posts
    Member since:
    Mar 2020

    Posted 17 Mar 2020 Link to this post

    Problem :

    Destroy doesn't go to the controller, What am i doing wrong?

    Read function works fine.

    Grid :

    <kendo-datasource name="dateSource2" type="DataSourceTagHelperType.Ajax" server-operation="false">
            <transport>
                <read url="/Begroting/GetBegrotingWijzigingen?filterElement=2-9" />
                <destroy url="/Begroting/RemoveBegrotingWijziging" />
            </transport>
            <schema>
                <model id="Id">
                </model>
            </schema>
        </kendo-datasource>
     
        <kendo-grid name="grid2" datasource-id="dateSource2">
            <groupable enabled="false" />
            <sortable enabled="true" />
            <scrollable enabled="true" />
            <filterable enabled="true" />
            <pageable button-count="5" refresh="true" page-sizes="new int[] { 5, 10, 20, 50, 100 }">
            </pageable>
            <columns>
                <column field="Datum" title="Datum" />
                <column field="Afdeling" title="Afdeling" />
                <column field="Combinatie" title="Combinatie" />
                <column field="Bedrag" title="Bedrag" />
                <column field="Toelichting" title="Toelichting" />
                <column>
                    <commands>
                        <column-command text="Delete" name="destroy"></column-command>
                    </commands>
                </column>
            </columns>
        </kendo-grid>

     

    Controller :

    [HttpPost]
       public IActionResult RemoveBegrotingWijziging([DataSourceRequest] DataSourceRequest request, BegrotingRecord begrotingRecord)
       {
           if (!begrotingRecord.Naarcoda)
           {
               _rW.BegrotingRepository.RemoveBegrotingRecord(begrotingRecord.Id);
           }
     
           return Json("OK");
       }
  2. Tsvetomir
    Admin
    Tsvetomir avatar
    796 posts

    Posted 19 Mar 2020 Link to this post

    Hi Maxime,

    I have investigated the provided code snippets and I have not noticed anything wrong with the declaration. However, what I have noticed is that the editable option is not specified. Is it possible for you to specify it as shown below?

    <editable mode="popup" />

    The editable option is needed to indicate to the grid that changes could be done to the data source, in this case, items to be deleted.

    I hope you find this helps.

     

    Regards,
    Tsvetomir
    Progress Telerik

    Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
Back to Top