I have 2 dropdown list in my page. In web browser (PC side) It works fine. There is no problem. When i open the page with chrome toogle device toolbar and i resize as mobile view, it only gives this error
fastclick.js:1 [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080
csHTML Code
<div class="tab-pane active tabcontent" id="reservationPage" role="tabpanel">
<div class="col-sm-12 col-md-12">
<div class="form-group row rowR">
<label class="form-control-label col-md-2"><strong>Yemekhane</strong> </label>
<div class="col-md-12">
#Html.DropDownListFor(x => x.RefectoryId, new SelectList(Model.Refectories, "Id", "Name"), ("Seçiniz"), new { Id = "RefectoryId", #class = "form-control select2" })
</div>
</div>
<div class="form-group row rowR">
<label class="form-control-label col-md-2"><strong>Öğün</strong> </label>
<div class="col-md-12">
#Html.DropDownListFor(x => x.FoodMealId, new SelectList(Model.FoodMeals, "Id", "Name"), ("Seçiniz"), new { Id = "FoodMealId", #class = "form-control select2" })
</div>
</div>
</div>
</div>
JS Code
<script>
var reservationCount = 0;
var totalAmount = 0;
$(document).ready(function () {
$("#reservationCount")[0].textContent = "(" + reservationCount + ")";
//İlk açıldığında rezervasyon sayfasının acık gelmesi için
var tablinks = document.getElementById("reservationPageHead");
tablinks.className = tablinks.className + " active";
document.getElementById('reservationPage').style.display = "block";
//var foodMealId = $("#FoodMealId").val();
//var refectoryId = $("#RefectoryId").val();
//GetCalendarMenuPartial(foodMealId, refectoryId);
$("#RefectoryId").select2({
allowClear: true,
placeholder: 'Yemekhane Seçiniz',
// dropdownParent: $(".bootbox-body"),
});
var refectorySelect = $('#RefectoryId');
refectorySelect.on("select2:select", function (e) {
var foodMealId = $("#FoodMealId").val();
var refectoryId = $("#RefectoryId").val();
$.ajax({
url: "#Url.Action("GetRefectoryWithFoodMeal", "Reservation", new { area = "Common" })",
data: { refectoryId: refectoryId },
type: "POST",
async: false,
success: function (returnData) {
if (returnData.data == undefined) {
PageToastr(returnData.type, returnData.message, returnData.title);
}
else {
//FoodMeal List
$("#FoodMealId option[value]").remove();
$("#FoodMealId").select2({
allowClear: true,
placeholder: 'Seçiniz',
data : returnData.data,
});
}
},
beforeSend: function () {
$(".loaderDiv").show();
$(".loader").show();
},
complete: function () {
$(".loaderDiv").hide();
$(".loader").hide();
},
error: function (xhr, status, err) {
if (xhr.status === 999) {
noAuthorize(this.url);
}
}
});
var foodMealId = $("#FoodMealId").val();
var refectoryId = $("#RefectoryId").val();
GetCalendarMenuPartial(foodMealId, refectoryId);
});
$("#FoodMealId").select2({
allowClear: true,
placeholder: 'Öğün Seçiniz',
//dropdownParent: $(".bootbox-body"),
});
var foodMealSelect = $('#FoodMealId');
foodMealSelect.on("select2:select", function (e) {
var foodMealId = $("#FoodMealId").val();
var refectoryId = $("#RefectoryId").val();
GetCalendarMenuPartial(foodMealId, refectoryId);
});
// Rezervasyonu tamamla için tooltip
$('#completeReservation').tooltip('update');
});
</script>
<script>
function GetCalendarMenuPartial(foodMealId, refectoryId) {
$.ajax({
url: '#Url.Action("NewReservationCalendarMenuPartial", "Reservation", new { area = "Common" })',
data: { foodMealId: foodMealId, refectoryId: refectoryId, addCardMenu: $("#AddCardMenuString").val() },
type: "POST",
success: function (partialPage) {
if (partialPage.title != undefined) {
PageToastr(partialPage.type, partialPage.message, partialPage.title);
if (partialPage.result == '#Enums.ResultStatus.SessionTimeExpired.ToString()') {
setTimeout(function () { window.location.href = '/Login/Login'; }, 5000)
}
}
else {
$("#calendarMenuPartial").html(partialPage);
}
},
beforeSend: function () {
$(".loaderDiv").show();
$(".loader").show();
},
complete: function () {
$(".loaderDiv").hide();
$(".loader").hide();
},
error: function (xhr, status, err) {
if (xhr.status === 999) {
noAuthorize(this.url);
}
}
});
}
</script>
After that I've added touch-action: none; but it doesn't work too. It works properly in PC Devices. But never works on mobile devices.
Related
The MeteorJS method "get.jade" is not returning jade object to client as expected. I'm using redis-livedata and manuel:reactivearray packages, and Redis is functioning locally correctly. I have put console.log in the code where there is a problem is returning server side data to client
jades.html
<template name="jades">
{{#if jadeslength}}
<div class="row">
<div class="user-card" id="swipe">
<img src="{{jade.img}}" style="width:100%">
<div class="card-container">
<h5>{{jade.name}}, {{jade.gender}}</h5>
</div>
</div>
</div>
<div class="row">
<div class="one-half column">
<button class="no" type="button">no</button>
</div>
<div class="one-half column">
<button class="button-primary yes" type="button">yes</button>
</div>
</div>
{{else}}
<div class="row">
<button class="button-primary search-jades" type="button" id="search">search</button>
</div>
{{/if}}
</template>
jades.js
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';
import './jades.html';
Template.jades.onCreated(function () {
var jades = new ReactiveArray([]);
Session.set({'jadeId':""});
});
Template.jades.helpers({
jade: function() {
return jades.list();
},
jadeslength: function() {
var jades = jades.list();
return jades.length;
},
});
Template.jades.events({
...
'click .search-jades' () {
Template.instance.jades = [];
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var client_location = {"lat": position.coords.latitude, "lng": position.coords.longitude};
if (client_location) {
var lng = client_location.lng;
var lat = client_location.lat;
Meteor.call('client.profile', (error, result) => {
if (error) {
FlashMessages.sendError(error, 3000);
} else {
var user_profile = result;
Session.set({'user_profile': user_profile});
var prefer = user_profile.prefer;
switch (prefer) {
case "cis women":
Meteor.call('search.cw', lng, lat, (error, result) => {
if (error) {
FlashMessages.sendError(error, 3000);
return;
} else {
searched = result;
if (searched.length == 0) {
FlashMessages.sendWarning("no more providers found in your area", 3000);
} else {
for (var found of searched) {
var user_profile = Session.get('user_profile');
var right = user_profile.right;
if (!(found._id in right)) {
Template.instance.jades.push(found._id);
}
}
var jadeId = Template.instance.jades.pop();
console.log(jadeId); // returns ofQj98LBQWrSJ8gJs on client
if (jadeId) {
Meteor.call('get.jade', jadeId, (error, result) => {
if (error) {
FlashMessages.sendError(error, 3000);
} else {
Session.set({'jadeId': jadeId});
Session.set({'jade': result});
console.log(result); // returns undefined on client
}
});
} else {
FlashMessages.sendWarning("no more providers found in your area", 3000);
}
}
}
});
break;
case "trans women":
...
methods.js
'get.jade': function(jadeId) {
var redisCollection = new Meteor.RedisCollection("redis");
redisCollection.hgetall(jadeId, function(error, object) {
if (error) {
console.log(error);
} else {
console.log(object); // returns { name: 'alex', img: 'null', gender: 'cis woman' } on server
return object;
}
});
},
I solved this by changing the method as follows:
'get.jade': function(jadeId) {
var redisCollection = new Meteor.RedisCollection("redis");
return redisCollection.hgetall(jadeId)
},
Here's the code showing what I have done. Basically I have done coding for Select All but it's outside the Kendo grid. What I need is to place a Select All checkbox inside the column header from where I can do Select All function, which I am doing now by above Select All which is placed outside the Kendo grid.
This is what i need
#{
Layout = "~/Views/Admin/_Layout.cshtml";
ViewBag.PageTitle = "Profile status";
TempData.Keep("ProfileName");
ViewBag.PageHeaderName = "Clean Profile";
}
<div class="card card-body dprediction mx-3">
<div class="form-horizontal">
<div class="accordion" id="CreateETLToolProfile">
<div class="form-group row flex-v-center px-3 pt-2">
<div class="col-md-6 pt-3"> #ViewBag.ProfileName</div>
<div class="col-md-6" style="text-align:right">
<span class="pt-2">
Select All Tables #Html.CheckBox("IsSelectAllTables",true,new { #OnClick = "CheckUncheckCheckBox();" , id = "IDIsSelectAllTables" })
</span>
<button class="btn btn-primary" id="btnRefresh"><i class="fa fa-refresh"></i></button>
</div>
</div>
<div style="padding:5px 15px;">
#(Html.Kendo().Grid<DRS.Model.DTO.CleanProfileModel>()
.Name("CleanProfileGrid")
.Columns(columns =>
{
columns.Bound(c => c.DESTINATIONTABLEID).Hidden();
columns.Bound(c => c.DestinationTableName).Title("Dest Table name");
columns.Bound(c => c.DestinationSPName).Title("Dest SP name");
columns.Bound(c => c.IsToBeCleaned).ClientTemplate("<input type='checkbox' #= IsToBeCleaned ? checked='checked' :'' # class='chkbx' />").Title("Tables To Be Cleaned").Filterable(false).HeaderTemplate("<label for='check - all'>Tables To Be Cleaned </label><input type='checkbox' #= IsToBeCleaned ? checked='checked' :'' # class='chkbx1' />");
})
.Pageable()
.Sortable()
.Resizable(r => r.Columns(true))
.Filterable(filterable => filterable.Mode(GridFilterMode.Menu))
.Editable(editable =>
{
editable.DisplayDeleteConfirmation(false);
})
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(m => m.ID);
})
.PageSize(20)
)
.Events(events => events.DataBound("LoadCleanProfileGrid"))
)
</div>
<div class="card-body text-right pr-3">
#Html.ActionLink("Cancel", "ViewProfiles", "Admin", null, new { #class = "btn btn-secondary" })
<button id="btnSave" type="button" value="Save" class="btn btn-success">
<span class="glyphicon glyphicon-floppy-save"></span>
<span>Clean Profile</span>
</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function LoadCleanProfileGrid() {
// CheckUncheckCheckBox();
}
$(document).ready(function () {
debugger;
AssingCleanProfileGrid();
});
var ds = new kendo.data.DataSource();
function AssingCleanProfileGrid() {
var grid = $('#CleanProfileGrid').data('kendoGrid');
grid.setDataSource(ds);
grid.dataSource.read();
ds = new kendo.data.DataSource({
type: "aspnetmvc-ajax",
transport: {
read: {
url: '#Url.Action("GetJsonProfileDataForCleanPanel", "Admin")',
type: "POST",
dataType: "json",
}
},
schema: {
data: "Data",
total: function (response) {
return response.Total;
},
model: {
}
},
// serverPaging: true,
page: 1,
pageSize: 20,
skip: 0,
take: 15,
// serverSorting: true,
});
grid.setDataSource(ds);
grid.dataSource.read();
}
var IsClickedOnSelectAll = true;
function CheckUncheckCheckBox() {
debugger;
var IsSelctAll = true;
IsSelctAll = $("#IDIsSelectAllTables").prop("checked");
// alert(IsSelctAll);
var grid = $("#CleanProfileGrid").data("kendoGrid");
// var gridData = grid.dataSource.view();
var gridData = $('#CleanProfileGrid').data().kendoGrid.dataSource.data();
for (var i = 0; i < gridData.length; i++) {
var firstItem = $('#CleanProfileGrid').data().kendoGrid.dataSource.data()[i];
firstItem.set('IsToBeCleaned', IsSelctAll);
}
IsClickedOnSelectAll = true;
}
$(function () {
$('#CleanProfileGrid').on('click', '.chkbx', function () {
var checked = $(this).is(':checked');
var grid = $('#CleanProfileGrid').data().kendoGrid;
var dataItem = grid.dataItem($(this).closest('tr'));
dataItem.set('IsToBeCleaned', checked);
if (IsClickedOnSelectAll) {
$("#IDIsSelectAllTables").prop("checked", checked);
IsClickedOnSelectAll = false;
}
})
})
$("#btnRefresh").click(function () {
location.reload(true);
})
$("#btnSave").click(function () {
debugger;
var gridmodel = $("#CleanProfileGrid").data("kendoGrid").dataSource.data();
var CleanProfileGrid = JSON.stringify(gridmodel);
var ProfileName = '#ViewBag.ProfileName';
var CleanProfileId = '#ViewBag.CleanProfileId';
debugger;
$.ajax({
url: "#Url.Action("CleanProfileData", "Admin")",
type: "POST",
//dataType: "JSON",
data: { CleanProfileGrid: CleanProfileGrid, ProfileName: ProfileName, CleanProfileId:CleanProfileId},
success: function (result) {
}
});
window.location.href ='#Url.Action("ViewProfiles", "Admin")';
});
</script>
The Kendo Grid actually supports checkbox selection out of the box:
https://demos.telerik.com/aspnet-mvc/grid/checkbox-selection
If you opt for the built in selection, you can persist the selection between operations - paging/sorting/filtering/grouping.
As noted in another answer here, the grid has a built-in Select All function.
But in case you require a custom look or behavior, you can use Kendo column header templates for this. First, define your custom header representing the header with checkbox. This can be placed above the grid:
#helper MyHeaderTemplate() {
<span style='text-align:right'>My<br/>Header<br/>Checkbox<br/></span>
#(Html.CheckBox("MySelectAllBox", false,
new
{
style = "font-size:inherit; margin-top:5px",
#onchange = "handleSelectAllClick(this)"
})
)
}
Then reference the template from your grid:
#(Html.Kendo().Grid<DRS.Model.DTO.CleanProfileModel>()
.Name("myGrid")
.Columns(columns =>
{
columns.Bound(p => p.MyColumnProperty)
.HtmlAttributes(new { style="text-align:center" })
.HeaderHtmlAttributes(new { style = "text-align:center" })
.HeaderTemplate(#<text>#MyHeaderTemplate()</text>);
})
)
Then write some JavaScript to handle the handleSelectAllClick event as needed to select or deselect all grid rows.
I am using react.js for displaying some data. I have more than one divs one below other. and each div contain graph, created from chart.js. I have one button in every div to display or hide that particular chart. It is working nicely. But when I hide that graph, my firefox is still not freeing up the space which was taken by chart when it was getting displayed. Like when I am hiding my chart, the space is getting created between two divs. The code is working properly in Microsoft Edge browser.
Here is my code:
var Div= React.createClass({
getInitialState: function () {
return {
displayChart: false
};
},
chartClick: function () {
this.setState({
displayChart: !this.state.displayChart,
});
},
render: function() {
return (
<div>
<p className="text-justify">
{ this.props.detail }
</p>
<button type="button" className="btn btn-link" onClick={ this.chartClick }>Chart</button>
{ this.state.displayChart ?
<ChartGraph id={this.props.id} />
: null }
</div>
);
}
});
Chart Component is :
ChartGraph = React.createClass({
onLoad: function () {
var barChartData = {
labels: [ option1, option2 ],
datasets: [
{
data: [451, 145],
fillColor: "rgba(46,145,202,0.8)",
strokeColor: "rgba(46,145,202,0.8)",
highlightFill: "rgba(46,145,202,1)",
highlightStroke: "rgba(46,145,202,1)"
}
]
};
var ctx = document.getElementById("canvas_poll"+this.props.id).getContext("2d")
new Chart(ctx).HorizontalBar(barChartData, {
scaleGridLineWidth: 1,
scaleShowGridLines: false,
scaleStartValue : 0
});
},
componentDidMount: function() {
this.onLoad();
},
render: function () {
return (
<div className="red">
<canvas id={"canvas_poll"+this.props.id} height="100" width="400"></canvas>
</div>
);
}
});
Any help for this problem?
Thank you..
This should work.
var Div= React.createClass({
getInitialState: function () {
return {
displayChart: false
};
},
chartClick: function () {
this.setState({
displayChart: !this.state.displayChart,
});
},
render: function() {
var hideChart = this.state.displayChart ? false : true;
return (
<div>
<p className="text-justify">
{ this.props.detail }
</p>
<button type="button" className="btn btn-link" onClick={ this.chartClick }>Chart</button>
<ChartGraph id={this.props.id} hide={hideChart} />
</div>
);
}
});
and
ChartGraph = React.createClass({
onLoad: function () {
var barChartData = {
labels: [ option1, option2 ],
datasets: [
{
data: [451, 145],
fillColor: "rgba(46,145,202,0.8)",
strokeColor: "rgba(46,145,202,0.8)",
highlightFill: "rgba(46,145,202,1)",
highlightStroke: "rgba(46,145,202,1)"
}
]
};
var ctx = document.getElementById("canvas_poll"+this.props.id).getContext("2d")
new Chart(ctx).HorizontalBar(barChartData, {
scaleGridLineWidth: 1,
scaleShowGridLines: false,
scaleStartValue : 0
});
},
componentDidMount: function() {
this.onLoad();
},
render: function () {
if (this.props.hide) return null;
return (
<div className="red">
<canvas id={"canvas_poll"+this.props.id} height="100" width="400"></canvas>
</div>
);
}
});
I am trying to get the selected row of a MVCGrid and display the details in an modal dialog using a partialview.
I am getting the selected row via ajax:
$(document).ready(function(){
var selectedRow;
$(document).on('click', '.grid-mvc', function () {
pageGrids.PersonGrid.onRowSelect(function (e) {
// $.prompt(e.row.ID);
SendData(e.row);
});
});
});
The 'SendData'-function is:
function SendData(i) {
var data= i.ID;
$.ajax({
url: '/Home/Person',
contentType: "application/html; charset=utf-8",
type: "GET",
data: { "id": daten },
dataType: "html"
, success: function () {
ShowPersonDetails(data);
}
});
}
and the ShowPersonDetails(data) is like that:
function ShowPersonDetails(data) {
$(document).ready(function () {
$('#PersonDiv').load("Person?id=" + data);
$("#PersonDiv").prompt(
$("#PersonDiv").html(),
{
title: "some title",
buttons: { OK: 'true', Abbruch: 'false' },
position: { width: 800, height: 600 }
});
});
}
The controller:
[HttpGet]
public ActionResult Person(int id)
{
var pS = new DbAccess(MvcApplication.Connection).GetUserData(id);
var p = new Person();
if (pS.Rows.Count < 0)
{
return PartialView("Person");
}
p.Alter = pS.Rows[0].ItemArray[0].ToString();
p.Nachname = pS.Rows[0].ItemArray[5].ToString();
return PartialView("Person", p);
}
Any advice would be nice!
Greetings
PP
i did something like you are trying to do, so hope my code helps
in the grid, table, i put a link for details
<tr>
<td>
#Html.ActionLink("Details", "ActionDetails", new { id = Model.LstItems[x].ID }, new { #class = "detailsLink" })
</td>
</tr>
the javascript
$('#detailsDialog').dialog({
autoOpen: false,
width: 400,
resizable: false,
modal: true,
buttons: {
"Cancel": function () {
$(this).dialog("close");
}
}
});
$(".detailsLink").button();
$(".detailsLink").click(function () {
linkObj = $(this);
var dialogDiv = $('#detailsDialog');
var viewUrl = linkObj.attr('href');
$.get(viewUrl, function (data) {
dialogDiv.html(data);
//open dialog
dialogDiv.dialog('open');
});
return false;
});
in somewhere in the view
<div id="detailsDialog" title="Offer Details">
</div>
the controller
public ActionResult ActionDetails(int id)
{
ItemEntity model = ItemEntity .GetBy(id);
return PartialView(model);
}
the partial view
#model YourNameSpace.Entities.ItemEntity
#using (Ajax.BeginForm("ActionDetails", "YourController", new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
HttpMethod = "POST",
OnSuccess = "updateSuccess",
OnFailure = "showErrorMessage"
}, new { #id = "detailForm" }))
{
//your details for your item
}
hope this help you
I have li tags that includes links to different pages. Now i am trying to create a searcj by clicking on specific li tag. I want when user clicks on this li named 'Field Workers', a sub li appears that includes names of all field workers that are in the database. Ajax code is used to diaplay the field workers. I am getting data in the ajax cide but somehow it is not getting displayed. Can anyone help me with this?
Ajax code:
<script>
var ajaxOptions = {
type: "POST", url: null, success: null, async: true,
data: "", dataType: "json", contentType: "application/json; charset=utf-8"
}
$(function () {
BindFW();
})
function BindFW() {
ajaxOptions.data = "";
ajaxOptions.url = "WebForm1.aspx/BindFieldWorkers"
ajaxOptions.success = function (result) {
if (result.d != null && result.d != "") {
//$("#templateFW").tmpl(result.d).appendTo("#ulFW");
$.each(result.d, function () {
$('#ulFW').append();
});
}
}
$.ajax(ajaxOptions);
}
</script>
<ul>
<li class="has-sub">
<a href="javascript:;">
<i class="icon-search"></i>
<span class="title">Field Worker Name</span>
<span class="arrow "></span>
</a>
<ul id="ulFW" class="sub">
</ul>
</li>
</ul>
use from this script:
$(document).ready(function () {
BindFW(10);
});
function BindFW(StateId) {
var data = {
StateId: StateId
};
$.ajax({
type: 'POST',
url: './WebForm1.aspx/BindFieldWorkers',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: JSON.stringify(data),
success: function (data) {
if (!data.d['Result']) {
alert('no records found!');
return;
}
var records = data.d['Records'];
for (var i = 0; i < records.length; i++) {
$('#ulFW').append(function () {
return $('<li>').text(records[i].Text).attr('data-id', records[i].ID)
});
}
},
error: function (data) {
alert('failed to connect to server!');
}
});
}
and this in your code behind:
[System.Web.Services.WebMethod]
public static object BindFieldWorkers(int StateId)
{
try
{
List<object> result = new List<object>();
for (int i = 0; i < 10; i++)
{
result.Add(new
{
ID = i,
Text = "Text " + i
});
}
return new { Result = true, Records = result };
}
catch (Exception ex)
{
return new { Result = false, Message = ex.Message };
}
}