my problem is, im attached the image, you can understand my problem, im try to fix it, more than 2 hours, i cant fix it, please help me to fix my problem.this is a advance search part of my project.,
enter image description here
<div class="col-md-12">
<div class="col-md-4">
<div class="modal fade" id="mpSrch" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" style="width: 95%">
<div class="modal-content">
<div class="modal-header btn-primary btn-sm" style="height: 40px;">
<button style="margin-top: -10px;" type="button" class="close btn-sm" data-dismiss="modal" aria-hidden="true">×</button>
<h6 style="margin-top: -5px;"><i class="glyphicon glyphicon-search"></i>Good Recieve Note</h6>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<div class="modal-content" style="margin-left: 27px;width: 1250px;padding: 2px;">
<table id="datatable" class="datatableDisplay" font-size:"11pt">
<thead>
<tr>
<th>Id</th>
<th style="width:150px;">GRN No</th>
<th style="width:150px;">GRN Date</th>
<th style="width:150px;">Company Name</th>
<th style="width:150px;">Purchase Order No</th>
<th style="width:150px;">Confirm Status</th>
<th>Action</th>
</tr>
</thead>
<tfoot>
<div id="eee">
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</div>
</tfoot>
</table>
<div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
$(document).on('click', '.selectid', function(e) {
e.preventDefault();
$('#hfRowItem1').val(parseInt($(this).parents('tr').children('td').eq(0).html()));
$('#btnFakeRowClick').trigger('click');
});
$(function Pageload() {
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function() {
$(document).ready(function() {
var dataTableInstance = $('#datatable').DataTable({
"iDisplayLength": 5,
"bStateSave": false,
"oLanguage": {
"sLengthMenu": 'Show <select><option value="5">5</option><option value="10">10</option></select> entries'
},
"bJQueryUI": true,
"bAutoWidth": false,
columns: [{
'data': 'GRNId',
className: 'hide_column'
}, {
'data': 'GRNNo'
},
{
'data': 'GRNDate',
'render': function(jsonDate) {
var date = new Date(parseInt(jsonDate.substr(6)));
var month = date.getMonth() + 1;
return ("0" + date.getDate()).slice(-2) + '/' + ("0" + month).slice(-2) + '/' + date.getFullYear();
}
},
{
'data': 'CompanyName'
}, {
'data': 'PurchaseOrderNo'
}, {
'data': 'ConfirmStatus'
}, {
'data': null,
className: "center",
defaultContent: 'Select',
'width': '5%'
}
],
bServerSide: true,
sAjaxSource: 'GenericHandlers/GoodReceiveNoteDataHandler.ashx'
});
$('#datatable tfoot th').each(function() {
if ($(this).index() != 0 && $(this).index() != 9) {
$(this).html('<input type="text" class="dtSrchCol" placeholder="Search">');
if ($(this).index() == 2) {
$(this).find('input').addClass('datetimepicker');
}
}
});
dataTableInstance.columns().every(function() {
var datatableColumn = this;
$(this.footer()).find('input').on('keyup change', function() {
datatableColumn.search(this.value).draw();
});
});
});
});
});
$(document).ready(Pageload);
Related
I'm new to Vue.js, so thanks for the help!!
I'm trying to implement a Search input for each column that filters the results for the user
this is my HTML file:
<div id="table" >
<div class=" container jumbotron mt-3 ">
<enter-data :resources="resources" ></enter-data>
</div>
<div class=" container jumbotron mt-1 ">
<table-list :resources="resources" :heads="heads" ></table-list>
</div>
</div>
And this is my JS file:
Vue.component('table-list', {
props: ['resources', 'heads'],
data () {
return {
selected: [],
selectAll: true,
userIds: [],
searchQuery: ''
}
},
computed: {
filteredResources: function () {
if (this.searchQuery) {
return this.resources.filter(item => {
// return this.item.value.toLowerCase().includes(this.searchQuery.toLowerCase());
// return this.searchQuery.toLowerCase().split(' ').every(v => item.value.toLowerCase().includes(v))
return this.item.FName.startsWith(this.searchQuery)
// return item.indexOf(this.searchQuery)>= 0;
})
} else {
return this.resources
}
}
},
methods: {
sortTable: function (resource) {
this.resources.sort(function (a, b) {
if (a[resource.value] > b[resource.value]) {
return 1
} else if (a[resource.value] < b[resource.value]) {
return -1
}
return 0
})
}
},
template: `
<div class="w-100 text-center d-flex justify-content-center flex-wrap">
<div class="w-75">
<!-- <input type="text" placeholder="search.." v-modle="searchQuery" >-->
<table class="table table-striped">
<thead>
<tr>
<th>
<input type="checkbox">
</th>
<th v-for="resource in heads" class="cursor" #click="sortTable(resource)">
<div />
{{ resource.name }}
</th>
</tr>
</thead>
<tbody>
<tr>
<td />
<td />
<td>
<input v-mode="searchQuery" type="text">
</td>
<td>
<input type="text">
</td>
</tr>
<tr v-for="resource in filteredResources">
<td>
<input type="checkbox">
</td>
<td v-for="column in heads">
{{ resource[column.value] }}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
`
})
var app = new Vue({
el: '#table',
data: {
resources: [
{ 'id': 0, 'FName': 'Setareh', 'LName': 'Pashapour', 'Extra': 'Alishah' },
{ 'id': 1, 'FName': 'Soheil', 'LName': 'Pashapour' },
{ 'id': 2, 'FName': 'Simin', 'LName': 'Hajizadeh' },
{ 'id': 3, 'FName': 'Nouyan', 'LName': 'Arman' },
{ 'id': 4, 'FName': 'Abed', 'LName': 'Hamrang' },
{ 'id': 5, 'FName': 'Navid', 'LName': 'Ahanj' }
],
heads: [{ name: '#', value: 'id' }, { name: 'First Name', value: 'FName' }, { name: 'Last Name', value: 'LName' }]
}
})
Unfortunately it doesn't work
searchQuery data doesn't have any impact to my filter computed and nothing happend if i type any thing on it
my Any suggestions?
You're using the wrong directive name for form input binding. Change from v-mode to v-model for below line.
<input v-mode="searchQuery" type="text">
I have a couple of vue pages, one page is a list of users, the second is a list of permissions and the third is a vue component
that displays the list of users and another vue component that shows the details of a user.
What I'm trying to do is, if I'm on the permissions page and I would like to go to a specific user's details I would like to redirect
with that panel open.
I am able to redirect the the users page by doing window.location.href = '/admin/users'; but I'm not sure how I'm going to get
the user panel open.
I thought that if I could do $emit then that could pass the user object over to the users main page, but that won't work if I do
a window.location.href = '/admin/users';
Here is my code. This has 2 components displays a list of users and their details
<template>
<div class="row">
<div class="col-md-6">
<users :emit="emit" :users="users"></users>
</div>
<div class="col-md-6">
<detail v-if="userDetails" :emit="emit" :user="manageUser"></detail>
</div>
</div>
</template>
<script>
export default {
props: ['emit', 'users'],
data() {
return {
userDetails: false,
manageUser: null
}
},
mounted() {
this.emit.$on('user', payload => {
this.manageUser = payload.user;
this.userDetails = true;
});
}
}
</script>
This is my users lists
<template>
<div class="card">
<div class="card-header">
<h3 class="card-title text-success" style="cursor: pointer;" #click="createUser"> New User</h3>
</div>
<div class="card-body">
<table class="table table-sm table-striped">
<thead>
<tr>
<th>Name</th>
<th style="width:120px;"></th>
</tr>
</thead>
<tbody>
<tr v-for="user in users">
<td>{{user.name}}</td>
<td style="text-align: right;">
<button class="btn btn-sm btn-outline-info" #click="detail(user)">Details</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
<script>
export default {
props: ['emit', 'users'],
data() {
return {
}
},
methods: {
detail(user) {
this.emit.$emit('user', { user: user });
}
}
}
</script>
and this is my permissions pages
<template>
<div class="card">
<div class="card-header">
<h3 class="card-title">{{permission.name}}</strong></h3>
</div>
<div class="card-body p-0">
<table class="table table-sm table-striped">
<thead>
<tr>
<th>User Name</th>
<th style="width:120px;"></th>
</tr>
</thead>
<tbody>
<tr v-for="user in users">
<td>{{user.name}}</td>
<td style="text-align: right;">
<button class="btn btn-sm btn-outline-info" #click="detail(user)">Details</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
<script>
export default {
props: ['emit'],
data() {
return {
users: []
}
},
mounted() {
this.allUsers();
},
methods: {
allUsers() {
this.loading = true;
axios.get('/users').then(response => {
this.users = response.data.users;
});
},
detail(user) {
window.location.href = '/admin/users';
}
}
}
</script>
I'm trying to get more then one class to show depending on what happens. For example if the user clicks on complete then my list is sorted to all the completed items, but what I would also like is that if a user clicks the done button then that item is hidden.
I did try this
<tr v-for="item in filteredItems" :class="[filteredItems.value, hide:item.pending]">
but that didn't work.
Here is my code
<template>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-3">
<ul class="list-group">
<li class="list-group-item" #click="setFilter('incomplete')">Not Complete</li>
<li class="list-group-item" #click="setFilter('complete')">Completed</li>
</ul>
</div>
<div class="col-md-9">
<table class="table table-striped table-sm mt-2">
<thead>
<tr>
<th>Description</th>
<th> </th>
</tr>
</thead>
<tbody>
<tr v-for="item in filteredItems" :class="filteredItems.value">
<td>
{{ item.title }}
</td>
<td>
<button type="button" class="btn btn-success btn-sm" #click="$set(item, 'pending', !item.pending)">Success</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data: function() {
return {
filter: 'all',
items: [{
id: '1',
title: 'Task 1',
value: "pending"
},
{
id: '2',
title: 'Task 2',
value: "complete"
},
{
id: '3',
title: 'Task 3',
value: "complete"
},
{
id: '4',
title: 'Task 4',
value: "pending"
}
],
pending: undefined
}
},
computed: {
filteredItems() {
if (this.filter === 'all') return this.items;
else return this.items.filter(item => item.value === this.filter);
}
},
methods: {
setFilter: function(filter) {
this.filter = filter;
},
setComplete: function(id){
// console.log('setComplete - '+id);
if(id)
{
// console.log(id);
}
}
}
}
</script>
<style>
.hide{
display: none;
}
</style>
You're very close. Use Object syntax instead of Array syntax in the inline binding.
<tr v-for="item in filteredItems" :class="{myClass: filteredItems.value, hide: item.pending}">
Documentation: https://v2.vuejs.org/v2/guide/class-and-style.html
I'm new to coding with a very basic understanding to Javascript. I created a table that will push an update to my tables upon clicking a button. However, i do want to limit the number of rows within my table. say for example upon pushing the sixth data to the table, i do want the first data to be removed from the row.
I tried searching everywhere with no luck. Maybe it's because my basic understand to javascript is pretty basic. Im a newbie haha. I am using vue.js for this code.
HTML
<form class="form-inline">
<div class="form-group mx-sm-3 mb-2">
<input
type="number"
v-model="newElement.buy"
class="form-control">
</div>
<button
v-on:click="buyStock"
type="button"
class="btn btn-success mb-2">BUY
</button>
</form>
<section class="stock_tables">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">{{codeBuy}}</th>
<th><a v-html="negative"></a> Buy</th>
</tr>
</thead>
<tbody>
<tr v-for="u in stocks">
<th></th>
<td>{{u.buy}}</td>
</tr>
</tbody>
</table>
</section>
Script
<script>
new Vue({
el: '#app',
data: {
codeBuy: "12345",
stocks: [],
newElement: {buy:"",sell:""}
},
methods: {
buyStock: function(){
this.stocks.push({buy:this.newElement.buy});
this.newElement = {buy:""};
}
}
});
</script>
So basically everytime i enter the amount of the stocks and press buy it will update.
You have some options to modify the buyStock method:
this.stocks.shift()
this.$delete(this.stocks, 0)
this.stocks = this.stocks.slice(1);
this.stocks = this.stocks.slice(-5);
this.stocks = this.stocks.splice(0, 1);
or, without the if use:
this.stocks = [...this.stocks, {
buy: this.newElement.buy
}].slice(-5);
Demo below:
new Vue({
el: '#app',
data: {
codeBuy: "12345",
stocks: [],
newElement: {
buy: "",
sell: ""
},
negative: ''
},
methods: {
buyStock: function() {
this.stocks.push({
buy: this.newElement.buy
});
if (this.stocks.length > 5) {
// this.$delete(this.stocks, 0);
// this.stocks = this.stocks.slice(1);
// this.stocks = this.stocks.slice(-5);
// this.stocks = this.stocks.splice(0, 1);
this.stocks.shift();
}
//this.stocks = [...this.stocks, {
// buy: this.newElement.buy
//}].slice(-5);
this.newElement = {
buy: ""
};
}
}
});
<script src="https://unpkg.com/vue"></script>
<div id="app">
<form class="form-inline">
<div class="form-group mx-sm-3 mb-2">
<input type="number" v-model="newElement.buy" class="form-control">
</div>
<button v-on:click="buyStock" type="button" class="btn btn-success mb-2">BUY</button>
</form>
<section class="stock_tables">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">{{codeBuy}}</th>
<th><a v-html="negative"></a> Buy</th>
</tr>
</thead>
<tbody>
<tr v-for="u in stocks">
<th></th>
<td>{{u.buy}}</td>
</tr>
</tbody>
</table>
</section>
</div>
I am working on Laravel + spark + vue js. Following is my code
app js
Vue.component('spark-emergency', {
data() {
return {
emergencies:[],
deleteEmergency:[],
editEmergency:[],
editEmergencyForm: new SparkForm({}),
deleteEmergencyForm: new SparkForm({}),
newEmergency: new SparkForm({
name: '',
type: '',
description:''
})
};
},
created() {
this.getEmergencies();
},
methods: {
getEmergencies() {
this.$http.get('/get-emergencies-plan-template')
.then(response => {
this.emergencies = response.data;
});
},
deleteEmergencyPlanTemplateConfirmation(emergency){
this.deleteEmergency = emergency
$('#modal-delete-emergency').modal('show');
},
deleteEmergencyPlanTemplate(){
Spark.delete(`/delete-emergencies-plan-template/${this.deleteEmergency.slug}`, this.deleteEmergencyForm)
.then(() => {
Bus.$emit('updateEmergencies');
$('#modal-delete-emergency').modal('hide');
});
},
createEmergencyPlanTemplate(){
Spark.post('/save-emergency-plan-template', this.newEmergency)
.then(() => {
this.newEmergency.name = '';
this.newEmergency.type = '';
this.newEmergency.description = '';
Bus.$emit('updateEmergencies');
});
},
editEmergencyPlanTemplate(emergency){
this.editEmergency = emergency
$('#modal-edit-emergency').modal('show');
},
updateEmergencyPlanTemplate(){
}
}
});
Blade file
<spark-emergency inline-template>
<div class="spark-screen container">
<div class="row">
<div class="col-md-12">
<!-- create new emergency -->
<div class="panel panel-default">
<div class="panel-heading">Create emergency</div>
<div class="panel-body">
<form class="form-horizontal" role="form"></form>
</div>
</div>
<!-- listing of emergencies -->
<div class="panel panel-default">
<div class="panel-heading">Emergencies Plan Template</div>
<div class="panel-body">
<table class="table table-borderless m-b-none">
<thead>
<th>Name</th>
<th></th>
</thead>
<tbody>
<tr v-for="emergency in emergencies">
<td>
<div class="btn-table-align">
#{{ emergency.name }}
</div>
</td>
<!-- Delete Button -->
<td>
<button class="btn btn-danger-outline" #click="deleteEmergencyPlanTemplateConfirmation(emergency)">
<i class="fa fa-times"></i>
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Edit Emergency Modal -->
<div class="modal fade" id="modal-edit-emergency" tabindex="-1" role="dialog"></div>
<!-- Delete Emergency Modal -->
<div class="modal fade" id="modal-delete-emergency" tabindex="-1" role="dialog"></div>
</div>
</div>
</div>
</spark-emergency>
Before adding add new and edit logic, it was working perfectly fine but after that Bus.$emit('updateEmergencies'); stopped working and now it is not working.
Any suggestions what can be the reason?