I am building an app using MVC using Jquery(KendoGrid) for displaying data, everything was working fine as per requirement, later we planned to add extra column with button present on each row of the grid, sounds simple, but tried number of ways to add into the application, getting error message "undefined 'node' ..... ", so i had no other options rather than posting here, if any one could able to help me in this will be appreciative, and i used column template on jquery kendo grid thanks
scenario
onclick of that button in specified row it should carry "ID(as shown below)" and redirect to "ActionResult" Controller, where I can further code as per my requirement
code(part of the code)
columns: [
{ field: "ID", Title: "ID", filterable: false, sortable: false, hidden: true },
{ field: "RowID", Title: "RowID", filterable: false, sortable: false, hidden: true },
{ field: "BillNumber", Title: "BillNumber", filterable: false, sortable: false,hidden:true },
{ field: "ServiceName", Title: "ServiceName",width:600 },
{ field: "ServiceStatus", Title: "ServiceStatus", width: 150 }
// Creating template column
, {
field: "Action", title: "Is Action", template: "<input type=\"checkbox\" #= Action ? checked='checked' : '' # class=\"check_row\"/> ", editable: false,
// field: "Action",title: "Preview ", template: '<input type="button" class="info" name="info" value="Info" style="height: 26px; margin: 0px 2px; min-width: 64px;" />',
headerTemplate: '<label> <input type="checkbox" id="checkAll"/>Print All</label>', filterable: false, sortable: false, width: 100,
}
currently I am able to generate checkbox in column, what i need is one more column with button(same as checkbox in each row)
Manjuboyz
Defining a button in a cell is pretty simple... basically you were doing it right.
Example: Define a column as:
columns: [
...
{
title: "Preview ",
template: '<input type="button" class="k-button info" name="info" value="Info" />',
headerTemplate: '<label> <input type="checkbox" id="checkAll"/>Print All</label>',
filterable: false,
sortable: false,
width: 100
}
]
Define the template as an input of type button. If you want it to look like a Kendo UI button add k-button class to it.
Then, you can bind a click handler doing:
$(".info").on("click", function() {
var row = $(this).closest("tr");
var item = grid.dataItem(row);
...
});
Where item contains all the data corresponding to the row that you clicked the button.
Running example here : http://jsfiddle.net/m8fsv/1/
EDIT: If what you need is to control / decide showing one or the other, you should change the template to something like:
<script id="template" type="text/kendo-template">
# if (showButton) { #
<input type="checkbox" #= data.Action ? checked="checked" : "" # class=\"check_row\"/>
# } else { #
<input type="button" class="k-button info" name="info" value="Info" />
# } #
</script>
You can check it here: http://jsfiddle.net/OnaBai/m8fsv/12/
Related
I am trying to create a table where the data can be edited directly in the cells. However, I don't understand how to do this.
I am using Vue.js, Vuexy and vue-good-table 2.21.1. The data is contained in the mediaPlanData variable and is reactive. The table is successfully populating with data and can be modified. However, when I change the data in the cells, this variable does not change. I did not find in the documentation vue-good-table how to do this. Please tell me how can I achieve the desired result?
<vue-good-table
:columns="columns"
:rows="mediaPlanData"
:select-options="{
enabled: true,
selectOnCheckboxOnly: true, // only select when checkbox is clicked instead of the row
selectionInfoClass: 'custom-class',
selectionText: 'rows selected',
clearSelectionText: 'clear',
disableSelectInfo: true, // disable the select info panel on top
selectAllByGroup: true, // when used in combination with a grouped table, add a checkbox in the header row to check/uncheck the entire group
}"
#on-selected-rows-change="onRowClick"
>
<template slot="table-row" slot-scope="props">
<span>
<b-form-input v-model="props.row[props.column.field]"
type="text"
></b-form-input>
</span>
</template>
</vue-good-table>
data() {
return {
pageLength: 10,
columns: [
{
label: 'Channel Code',
field: 'channelCode',
},
{
label: 'Product',
field: 'product',
}
],
mediaPlanData: [] //[ {"channelCode": "P230", "product": "Test"}, {"channelCode": "P230", "product": "Test4"}, {"channelCode": "P230", "product": "Test45"}, {"channelCode": "Р230", "product": "Test2"}]
}
}
methods: {
onRowClick(params) {
console.log('onRowClick' + JSON.stringify(params))
this.$toast({
component: ToastificationContent,
props: {
title: `Hello user! You have clicked on row ${params.selectedRows.product}`,
icon: 'UserIcon',
variant: 'success',
},
})
}
}
I have solved this problem.
Added to b-form-input
#change="changeCell(props.row[props.column.field], props.column.field, props.row.originalIndex)"
And adden method
changeCell(changedData, column, row) {
this.mediaPlanData[row][column] = changedData
},
I have a detail about an object inside my object fetched from the API. I would like to add a loop inside of the modal to show the details when I click.
data: function() {
return {
fields: [
{ key: 'customerOrderDelay', label: this.$t('metricsTable.column-name34'), sortable: true, class: 'text-center' },
{ key: 'supplierOrders', label: "suppllier order", sortable: true, class: 'text-center' },
{ key: 'actions', label: 'Actions' }
]
}
}
SupplierOrders is an object and I want to print the details with a loop inside the modal:
<b-modal :id="infoModal.id" :title="infoModal.item.orderAmount" ok-only #hide="resetInfoModal">
<!-- <pre>{{ infoModal.content }}</pre> -->
<div v-for="foo in infoModal.item.supplierOrders" ><md-card md-with-hover>
<md-ripple>
<md-card-header>
<div class="md-title">{{foo.supplierOrderNumber}}</div>
<div class="md-subhead">{{foo.supplierName}}</div>
</md-card-header>
<md-card-content>
{{foo.sectionName}}
</md-card-content>
<md-card-actions>
</md-card-actions>
</md-ripple>
</md-card>
the table :
<b-table
:tbody-tr-class="rowClass"
:busy="isBusy"
responsive="true"
:sticky-header="stickyHeader"
small
:items="totalOrders"
:fields="fields"
:per-page="300"
:filterIncludedFields="filterOn"
:sort-by="sortBy"
#sort-changed="sortTable"
>
It seems that I cannot access the object inside the object used by bootstrap-vue's table: Does anyone know how to override it?
guys, I m new to vue so don't know how to achieve following situation
how i can get data of current selected row
here is code
<div class="table-responsive-sm">
<vue-good-table
title="Page List"
:columns="columns1"
:rows="rows1"
:paginationOptions="{enabled: false}">
<template slot="table-row-after" slot-scope="props" >
<td class="fancy"><input type="checkbox" v-model="checkview[props.row.originalIndex]">
</td>
<td class="has-text-right"><input type="checkbox" v-model="checkedit[props.row.originalIndex]"></td>
<td class="has-text-right"><input type="checkbox" v-model="checkupate[props.row.originalIndex]"></td>
<td class="has-text-right"><input type="checkbox" v-model="checkdelete[props.row.originalIndex]"></td>
</template>
</vue-good-table>
columns1: [
{
label: 'Page Name',
field: 'pagename',
sortable: false,
},
{
label: 'View',
sortable: false,
},
{
label: 'edit',
sortable: false,
},
{
label: 'update',
sortable: false,
},
{
label: 'delete',
sortable: false,
},
],
rows1:[],
methods:{
getTotals1(){
var self = this;
this.$http.get('http://localhost:3000/api/permissionpgs')
.then(function (response) {
console.log(response.data)
self.rows1 = response.data;
})
},
}
is there any way to get data of value when save method got trigger. last ting this is vue good table
you're storing the values of checked items in 3 different objects. checkedit, checkupdate and checkdelete. If the user checks/unchecks your checkboxes in the table. These objects will have the following form:
checkupdate{
2: true, // index of the row: whether checked or unchecked
5: false,
20: true
}
now to get the rows for each of these objects all you have to do is loop through the object properties, collect the index that has value as true. then do this.rows1[index] to get the actual row object.
This is my first time using this website. Today is my debut into Kendo UI. My boss has bought it, and set me on it with high hopes! I absolutely love it if I'm honest but I have got stuck on an issue, I have Googled every possible search phrase but can't seem find a resolve. So I'm going to post this request and go to bed, hoping for the best. I'd have had my first task done in a day if it wasn't for this niggle :/
I'm looking to add the date to a PDF export in Kendo UI.
Here is my code...
$("#grid").kendoGrid({
toolbar: ["excel", "pdf"],
excel: {
fileName: "FlexibleSalesReport-"+ fileNameDate + ".xlsx",
proxyURL: "//demos.telerik.com/kendo-ui/service/export",
filterable: true
},
pdf: {
allPages: true,
avoidLinks: true,
paperSize: "A4",
margin: { top: "2cm", left: "0.5cm", right: "0.5cm", bottom: "1cm" },
landscape: true,
repeatHeaders: true,
template: $("#page-template").html(),
scale: 0.6,
date: new Date(),
title: 'My Title',
subject: 'My subject'
},
dataSource: {
//type: "odata",
// transport: {
// read: "//demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
// },
data: products,
schema: {
model: {
fields: {
Name: { type: "string" },
WebName: { type: "string" },
Code: { type: "string" },
Icing: { type: "string" },
Filling: { type: "string" },
AssociatedOrderingPage: { type: "string" },
Sold: { type: "number" },
TotalValue: { type: "string "}
}
}
},
pageSize: 10,
serverPaging: false,
serverFiltering: false,
},
height: 980,
filterable: {
mode: "row"
},
pageable: true,
sortable: true,
columns:
['Data removed for brevity']
});
I have added the date option, I'm not sure where to pull that option out of in the template. Below is my code for the template. Because it is in script tags, I cannot call functions or inject data into the span tags to add a date to the end of the of the pdf title.
<script type="x/kendo-template" id="page-template">
<div class="page-template">
<div class="header">
<div style="float: right">Page #: pageNum # of #: totalPages #</div>
########### Sales Report - <span id="thisOne"></span><!-- I'd like to inject into this span, even this comment isn't commented out in my IDE {VS Code}
</div>
<div class="watermark">#####</div>
<div class="footer">
Page #: pageNum # of #: totalPages #
</div>
</div>
</script>
The intended result
Thanks in advance and though I've read through the do's and don'ts. I'm open to constructive criticism on my addition
Okay. So after more research. I found the solution which I'll share with you guys.
To define any custom Javascript in the template, you must add it between hash tags (pound signs to some people).
For example:
# var foo = "bar"; #
Then to print the variable to the report, you use the following syntax:
#= foo #
The solution to my problem was replacing the template section with
<script type="x/kendo-template" id="page-template">
#
var theDate = new Date();
#
<div class="page-template">
<div class="header">
<div style="float: right">Page #: pageNum # of #: totalPages #</div>
[Obfuscated for client privacy] Flexible Sales Report - <span>#=theDate#</span>
</div>
<div class="watermark">[Obfuscated for client privacy]</div>
<div class="footer">
Page #: pageNum # of #: totalPages #:
</div>
</div>
</script>
I sincerely hope this helps someone.
I have this code but the label does not show up:
var radioOne = new RadioButton({
label: "Current",
style: "margin-left:10px",
checked: true
}).placeAt(userDiv);
Do I have to do a domCreate of an actual label tag?
I've gone ahead and am using this to create the label tag.
var label = domConstruct.create("label", {
for: "Previous",
style: "margin-left:5px",
innerHTML: "Previous"
}, userDiv);
this does work but seems this should be included in the RadioButton widget.
Yes you do. This was from the dojo documentations:
Script:
var radioOne = new RadioButton({
checked: true,
value: "tea",
name: "drink",
}, "radioOne");
HTML:
<input type="radio" name="drink" id="radioOne" checked value="tea"/> <label for="radioOne">Tea</label>