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

asp.net core 3 tag helper help

2 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bruce
Top achievements
Rank 1
Bruce asked on 26 Sep 2019, 07:45 PM

Please help me with the TagHelper equivalent of the following code.

ps. A suggestion for your documentation team; please include more useful examples like you have for the razor code -> the one read-only example is trivial and on the border of being useless.

@(Html.Kendo().Grid<OrderViewModel>
    ()
    .Name("grid2")
    .Columns(columns =>
    {
        columns.Bound(p => p.OrderID).Width(100);
        columns.Bound(p => p.Freight);
        columns.Bound(p => p.OrderDate).Format("{0:yyyy-MM-dd HH:mm:ss}");
        columns.Bound(p => p.ShipName);
        columns.Bound(p => p.ShipCity);
 
        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(250);
    })
    .ToolBar(toolbar => toolbar.Search())
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .Pageable()
    .Sortable()
    .Scrollable()
    .HtmlAttributes(new { style = "height:430px;" })
    .DataSource(dataSource => dataSource
    .Ajax()
    .ServerOperation(false)
    .PageSize(80)
    //.Events(events => events.Error("error_handler"))
    .Model(model => model.Id(p => p.OrderID))  
    .Read(read => read.Action("Orders_Read", "Grid")) 
    .Create(create => create.Action("Orders_Create","Grid"))
    .Destroy(update => update.Action("Orders_Destroy", "Grid"))
    .Update(update => update.Action("Orders_Update", "Grid"))
    )
 
)

I have tried with the following but have not succeeded in getting the destroy event to fire properly.

<kendo-grid name="grid1" height="550">
           <columns>
               <column field="OrderID" title="Order ID">
                   <filterable enabled="false"></filterable>
               </column>
               <column field="Freight" title="Freight" />
               <column field="OrderDate" title="Order Date" format="{0:MM/dd/yyyy}" />
               <column field="ShipName" title="Ship Name" />
               <column field="ShipCity" title="Ship City" />
               <column>
                   <commands>
                       <column-command text="Delete" name="destroy"></column-command>
                       <column-command text="Edit" name="edit"></column-command>
                   </commands>
               </column>
           </columns>
           <scrollable enabled="true" />
           <sortable enabled="true" />
           <pageable enabled="true" />
           <editable mode="inline" />
           <filterable enabled="true" />
           <datasource type="DataSourceTagHelperType.Ajax" page-size="20" server-operation="false">
               <transport>
                   <read url="@Url.Action("Orders_Read", "Grid")" />
                   <destroy url="@Url.Action("Orders_Destroy", "Grid")" />
               </transport>
               <schema>
                   <model>
                       <fields>
                           <field name="OrderId" type="int"></field>
                           <field name="Freight" type="decimal"></field>
                           <field name="OrderDate" type="DateTime"></field>
                           <field name="ShipName" type="string"></field>
                           <field name="ShipCity" type="string"></field>
                       </fields>
                   </model>
               </schema>
           </datasource>
       </kendo-grid>

2 Answers, 1 is accepted

Sort by
0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 01 Oct 2019, 02:56 PM

Hello, Bruce,

Thank you very much for sharing your feedback on the TagHelpers documentation. They are the newest addition chronologically in the newest Kendo UI flavour that we have and indeed their documentation is very scarce. However, the more people use them, the higher their priority becomes in the documentation tasks that we have in our queue.

I know that the TagHelps deserve their own extensive documentation but until we have it, I find that the jQuery documentation property names and structure is much closer to them than the HTML Helpers syntax.

Now - for the question at hand - the model id is missing from the configuration and the editing functionality cannot work without it. We have the id set in the editing example in the article but perhaps we could add an important note there to highlight it?

https://docs.telerik.com/aspnet-core/tag-helpers/data-management/grid/editing#getting-started

 

<schema  >
            <model id="OrderID">

 

Let me know in case further questions arise. Is that the only thing that was needed?

Regards,
Alex Hajigeorgieva
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Bruce
Top achievements
Rank 1
answered on 01 Oct 2019, 03:03 PM

Thank you Alex!

The delete event is now posting to the controller. 

Tags
Grid
Asked by
Bruce
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Bruce
Top achievements
Rank 1
Share this question
or