Hi team,
I am trying to select a field value when I do click with a custom button in the toolbar grid nothing happened, I am doing this way:
@Html.EJS().Grid("gvProceduresToInvoice").DataSource((IEnumerable<object>)ViewBag.ProceduresToInvoice).ToolbarClick("toolbarClick").Height("500px").AllowFiltering().AllowSorting().Columns(col =>
function toolbarClick(args) {
var gridobj = document.getElementById("gvProceduresToInvoice").ej2_instances[0];
if (args.item.id === 'btnInvoice') {
alert(args.rowData.CODE)
}
Thanks,
Hi team,
Thanks for your support, I am trying to select the field of the row selected for two propose:
@{
List<object> toolbarItems = new List<object>();
toolbarItems.Add("Search");
toolbarItems.Add(new { text = "Facturar", id = "btnFacturar" });
}
@Html.EJS().Grid("gvProceduresToInvoice").DataSource((IEnumerable<object>)ViewBag.ProceduresToInvoice).ToolbarClick("toolbarClick").Height("500px").AllowFiltering().AllowSorting().Columns(col =>
{
col.Field("ID_QUOTE_EMBARQUES").IsPrimaryKey(true).AllowEditing(false).Visible(false).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("50").Add();
col.Field("EXPEDIENTCODE").HeaderText("No. Expediente").AllowEditing(false).ValidationRules(new { maxLength = 12 }).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).HeaderTextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Width("250").Template("#ExpedientCode").Add();
col.Field("CODE").HeaderText("Conocimiento Embarque").ValidationRules(new { maxLength = 250 }).ValidationRules(new { required = true }).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).HeaderTextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Width("250").Add();
}).Locale("es-HN").AllowPaging().PageSettings(page => page.PageCount(5)).FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.Excel); }).Toolbar(toolbarItems).Render()
</div>
<script type="text/x-jsrender" id="ExpedientCode">
<a rel='nofollow' rel='nofollow' rel='nofollow' href='../Embarques/FileManager/?fileManager=${EXPEDIENTCODE}'>${EXPEDIENTCODE}</a>
</script>
<script>
function toolbarClick(args) {
var gridobj = document.getElementById("gvProceduresToInvoice").ej2_instances[0];
if (args.item.id === 'btnFacturar') {
alert(args.item.rowData.CODE);
var selectedRow = gridobj.getSelectedRecords();
var data = JSON.stringify(selectedRow);
console.log(JSON.parse(data).result);
}
}
</script>
Thanks,
|
toolbarClick(args) { //toolbar click event
if(args.item.id === 'custombutton') {
var getselectedrecords = grid.getSelectedRecords()[0]; //get the selected records
var getfield = (getselectedrecords as any).FirstName //get the field value from the selected records
alert(getfield);
}
}; |