Hello folks
I got this one nearly done. I can see that it is hitting my controller in the background but the refresh just keeps spinning :)
@model myHinkleyWebApp.Models.ItemInventory
<div id="table_data"><hr /><div class="row"><div class="col-12 padding-0"><h5>Check Product Availability</h5><div class="k-d-flex k-justify-content-left" style="padding-top: 54px;"><div class="k-w-100 text-left">
@{Html.RenderPartial("../Shared/EditorTemplates/Item_Search_Editor");}
</div><div class="k-w-200 text-left"><input id="btnSubmit" type="submit" style="margin-left: 25px;" value="Submit" class="btn btn-outline-primary" name="submit" /></div></div>
@(Html.Kendo().Grid<myHinkleyWebApp.Models.ItemInventory>()
.Name("ItemInventory")
.Columns(columns => {
columns.Bound(p => p.Item_no);
columns.Bound(p => p.Family);
columns.Bound(p => p.Status);
columns.Bound(p => p.DNPrice);
columns.Bound(p => p.MapPrice);
columns.Bound(p => p.QuantityAvailable);
columns.Bound(p => p.QuantityConfirmed);
columns.Bound(p => p.ConfirmedPromiseDate);
//columns.Bound(p => p.inventory_id).Title("").ClientTemplate("<a href='" + Url.Action("Delete", new { id = "#=inventory_id#", m_id = "#=customer_id#" }) + "'>Delete</a>");
//columns.Command(command => command.Destroy()).Width(150);
})
.ToolBar(tools => tools.Excel())
//.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Navigatable()
.Sortable()
//.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
//.Model(model => { model.Id(p => p.inventory_id); model.Field(p => p.inventory_id).DefaultValue(Guid.Empty); model.Field(p => p.customer_id).DefaultValue(Guid.Empty); })
//.Create("Item_Create_Update", "HLI_Customer_Specific_Inventory", new { CusNo = Model.CusNo })
//.Read("SearchItems_ByNameOrFamily", "ItemInventory", new {search_phrase = ViewBag.SearchPhrase})
//.Update("Item_Create_Update", "HLI_Customer_Specific_Inventory", new { CusNo = Model.CusNo })
//.Destroy("Item_Destroy", "HLI_Customer_Specific_Inventory", new { CusNo = Model.CusNo })
)
)
</div><br /><br /></div></div><script>
function error_handler(e) {
if (e.errors) {
var message = "Errors:\n";
$.each(e.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n";
});
}
});
alert(message);
}
}
$("#btnSubmit").click(function () {
var ItemInventory = $("#ItemInventory").data("kendoGrid");
$filter = new Array();
var ITEM = $("#item_no").val();
$.ajax({
type: "POST",
url: "/ItemInventory/SearchItems_ByNameOrFamily",
data: { search_phrase: ITEM },
dataType: "json",
success: function (result) {
var ds = new kendo.data.HierarchicalDataSource({
data: result
});
ItemInventory.setDataSource(ds);
ItemInventory.read();
ItemInventory.refresh();
}
});
//ItemInventory.dataSource.read();
});
</script>
After I click the button the grid is just spinning here is a view of that:
So really the help I need is with this javascript here:
$("#btnSubmit").click(function () {
var ItemInventory = $("#ItemInventory").data("kendoGrid");
$filter = new Array();
var ITEM = $("#item_no").val();
$.ajax({
type: "POST",
url: "/ItemInventory/SearchItems_ByNameOrFamily",
data: { search_phrase: ITEM },
dataType: "json",
success: function (result) {
var ds = new kendo.data.HierarchicalDataSource({
data: result
});
ItemInventory.setDataSource(ds);
ItemInventory.read();
ItemInventory.refresh();
}
});
//ItemInventory.dataSource.read();
});
To summarize I have a auto complete text box where I am entering an item. Then i want to push the button and refresh my grid which will pass the
item number and search for it and bring it back down in the grid!
Any help would be greatly appreciated!
Anyways here is my front end code here
I have API hosted on asp net core, through Swagger and Postman it works just fine, but when I try to access it through Jquery Grid of Kendo it only reads data but doesn't add nor delete.
Can you tell me what am I doing wrong here?
[HttpDelete]
public async Task<ActionResult> Delete(Guid id)
{
await _mediator.Send(new DeleteProductCommand.Command { Id = id });
return NoContent();
}
[HttpPost]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<ProductResponse>> Create([FromBody] CreateProductCommand command) => await _mediator.Send(command);
<script>
$(document).ready(function () {
var crudServiceBaseUrl = "https://localhost:44393/api",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/Product",
dataType: "json"
},
create: {
url: crudServiceBaseUrl + "/Product/Create",
contentType: "application/json; charset=utf-8",
dataType: "json",
type: "POST"
},
destroy: {
url: crudServiceBaseUrl + "/Product/Delete",
type: "DELETE",
contentType: 'application/json; charset=utf-8',
dataType: 'json'
},
parameterMap: function (options, operation) {
if (operation !== "read" && options) {
return kendo.stringify(options);
}
}
},
batch: true,
pageSize: 20,
schema: {
model: {
id: "id",
fields: {
id: { editable: false, nullable: false },
productName: { type: "string", editable: true },
productSKU: { type: "string", editable: true },
productType: { type: "string", editable: true },
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
columnMenu: {
filterable: false
},
height: 680,
editable: "inline",
pageable: true,
sortable: true,
navigatable: true,
resizable: true,
reorderable: true,
groupable: true,
filterable: true,
dataBound: onDataBound,
toolbar: ["excel", "pdf", "create", "search", "save", "delete"],
columns: [{
selectable: true,
width: 75,
attributes: {
"class": "checkbox-align",
},
headerAttributes: {
"class": "checkbox-align",
}
}, {
field: "productName",
title: "Product Name",
template: "productName",
width: 300
}, {
field: "productSKU",
title: "productSKU",
width: 105
}, {
field: "productType",
title: "productType",
width: 130,
}, {
field: "id",
title: "id",
width: 105
},
{ command: "destroy", title: "Action", width: 120 }],
});
});
function onDataBound(e) {
} ;
</script>
Hello,
I have a kendo editable grid with one column only. this column adds a textbox rowwhen a button named 'Add' is pressed. If no text is put into the box and the user leaves the textbox an empty row is created.
We had allowed 'required' model validation to trigger the kendo inbuilt validation tooltip however it is not compliant with our UX standards.
I therefore would like to destroy the textbox on the mouse leave if the textbox is empty.
I have tried and failed to find and trigger the mouse leave event.
Here is my grid.
@(Html.Kendo().Grid(Model.MyModelProps)
.Name("myeditabletable")
.ToolBar(tools => tools.Create().IconClass("fas fa-plus").Text("Add").HtmlAttributes( new { @class = "btn btn-primary whiteText" }))
.Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
.Columns(columns =>
{
columns.Bound(p => p.Id).Hidden().ClientTemplate("#= Id #" +
"<input type='hidden' name='MyModelProps[#= index(data)#].Id' value='#= Id #' />"
);
columns.Bound(p => p.MyModelProp).Title("<b>Synonym</b>").Editable("myeditabletable").ClientTemplate("#= Name #" +
"<input type='hidden' name='MyModelProps[#= index(data)#].Name' value='#= Name #' />"
);
columns.Command(command => command.Destroy().Text(" ")
})
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(p => p.Id);
})
.ServerOperation(false)
)
)