I have implemented data-tables fixed columns on project, the first (patients_report) data-tables report works very well but the second(visitation_report) one fails please advise how can I solve this problem ?
Below is my code :
<script type="text/javascript" src="http://www.datatables.net/release-datatables/media/js/jquery.js"></script>
<script type="text/javascript" src="http://www.datatables.net/release-datatables/media/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="http://www.datatables.net/release-datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js"></script>
<link href='http://www.datatables.net/release-datatables/media/css/jquery.dataTables.css' rel='stylesheet'>
<link href='http://www.datatables.net/release-datatables/extensions/FixedColumns/css/dataTables.fixedColumns.css' rel='stylesheet'>
<script type="text/javascript">
var j = jQuery.noConflict();
j(document).ready(function () {
j(document).ready(function () {
var table = j('.patients_report').DataTable({
scrollY: "300px",
scrollX: true,
scrollCollapse: true,
paging: false
});
new j.fn.dataTable.FixedColumns(table, {
leftColumns: 0,
rightColumns: 1
});
fc.fnUpdate();
});
j(document).ready(function () {
var visitation_table = j('.visitation_report').DataTable({
scrollY: "300px",
scrollX: true,
scrollCollapse: true,
paging: false
});
new j.fn.dataTable.FixedColumns(visitation_table, {
leftColumns: 0,
rightColumns: 1
});
fc.fnUpdate();
});
j('.edit_patient_link').click(function () {
//get data
var patient_id = j(this).closest('tr').find('input[name="view_patient_id"]').val();
j.ajax({
type: "GET",
url: "<?php echo base_url(); ?>reports/get_patient_reports_details/" + patient_id,
dataType: "json",
success: function (response) {
j('#edit_patient_id').val(response[0].patient_id);
j('#edit_title').val(response[0].title);
j('#edit_phone_no').val(response[0].phone_no);
j('#edit_inputFirstName').val(response[0].f_name);
j('#edit_inputSurName').val(response[0].s_name);
j('#edit_inputOtherName').val(response[0].other_name);
j('#edit_dob').val(response[0].dob);
j('#edit_gender').val(response[0].gender);
j('#edit_maritalstatus').val(response[0].marital_status);
j('#edit_nationalid').val(response[0].identification_number);
j('#edit_email').val(response[0].email);
j('#edit_address').val(response[0].address);
j('#edit_residence').val(response[0].residence);
j('#edit_employement_status').val(response[0].employment_status);
j('#edit_employers_name').val(response[0].employer);
j('#edit_kinname').val(response[0].next_of_kin_fname);
j('#edit_kinsname').val(response[0].next_of_kin_lname);
j('#edit_kinrelation').val(response[0].next_of_kin_relation);
j('#edit_kinphone').val(response[0].next_of_kin_phone);
j('#edit_family_number').val(response[0].family_base_number);
},
error: function (data) {
}
});
});
j('.view_patient_link').click(function () {
//get data
var patient_id = j(this).closest('tr').find('input[name="view_patient_id"]').val();
j.ajax({
type: "GET",
url: "<?php echo base_url(); ?>reports/get_patient_reports_details/" + patient_id,
dataType: "json",
success: function (response) {
j('#view_patient_id').val(response[0].patient_id);
j('#view_title').val(response[0].title);
j('#view_phone_no').val(response[0].phone_no);
j('#view_inputFirstName').val(response[0].f_name);
j('#view_inputSurName').val(response[0].s_name);
j('#view_inputOtherName').val(response[0].other_name);
j('#view_dob').val(response[0].dob);
j('#view_gender').val(response[0].gender);
j('#view_maritalstatus').val(response[0].marital_status);
j('#view_nationalid').val(response[0].identification_number);
j('#view_email').val(response[0].email);
j('#view_residence').val(response[0].residence);
j('#view_employement_status').val(response[0].employment_status);
j('#view_employers_name').val(response[0].employer);
j('#view_kinname').val(response[0].next_of_kin_fname);
j('#view_kinsname').val(response[0].next_of_kin_lname);
j('#view_kinrelation').val(response[0].next_of_kin_relation);
j('#view_kinphone').val(response[0].next_of_kin_phone);
j('#view_family_number').val(response[0].family_base_number);
},
error: function (data) {
}
});
});
j('.delete_patient_link').click(function () {
//get data
var patient_id = j(this).closest('tr').find('input[name="view_patient_id"]').val();
j('.input_patient_id_delete').val(patient_id);
});
});
</script>
<style>
/* Ensure that the demo table scrolls */
th, td { white-space: nowrap; }
div.dataTables_wrapper {
width: 1000px;
margin: 0 auto;
}
</style>
I can't see clearly what is the problem with your code. But I assume that is in first part, so put everything in single document ready event. Like this :
j(document).ready(function () {
var table = j('.patients_report').DataTable({
scrollY: "300px",
scrollX: true,
scrollCollapse: true,
paging: false
});
new j.fn.dataTable.FixedColumns(table, {
leftColumns: 0,
rightColumns: 1
});
table.fnUpdate();
var visitation_table = j('.visitation_report').DataTable({
scrollY: "300px",
scrollX: true,
scrollCollapse: true,
paging: false
});
new j.fn.dataTable.FixedColumns(visitation_table, {
leftColumns: 0,
rightColumns: 1
});
visitation_table.fnUpdate();
// rest of code
...
}); // close document ready event callback
There is fc.fnUpdate(); but I can't find fc variable nowhere. That should have been dataTable object. I hope this will do the trick. Good luck with project.
Related
Script for search column:
<script>
$.fn.dataTable.ext.errMode = 'none';
var tableObj;
$(document).ready(function(){
// debugger;
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
tableObj = $('{{ $class_name }}').DataTable({
searchable: true,
processing: true,
serverSide: true,
"aaSorting": [],
cache: true,
type: 'GET',
ajax: '{{ $routeValue }}',
#if(isset($table_columns))
columns: {!!$setData!!}
#endif
initComplete: function () {
this.api().columns().every(function () {
var column = this;
var input = document.createElement("input");
$(input).appendTo($(column.header()))
.on('keyup', function () {
column.search($(this).val(), false, false, true).draw();
});
});
}
});
$('.datatable').find('select.form-control').removeClass('form-control input-sm').addClass('full-width').attr('data-init-plugin','select2');
});
// console.log("it is working");
</script>
Controller function to get data:
$records = array();
dd($record);
$records = User::join('roles', 'users.role_id', '=', 'roles.id')
->select(['users.id','users.name', 'phone','users.default_bill_address','area','users.created_at','website','user_status','reason_inactive','is_online','login_enabled','role_id',
'slug'])->orderBy('users.created_at', 'desc');
if(!isset($_GET['order'])){
$records = $records ->whereIn('users.id',$list_his)->orderBy('users.created_at', 'desc');
}
return Datatables::of($records)
->editColumn ('default_bill_address', function($records){
if($records->default_bill_address)
{
$add = Address::where('id',$records->default_bill_address)->first();
if($add)
return $add->fullAddress();
else
return '-';
}
else
return '-';
})
Screenshot:
screenshot related to panel where search column is present.
Description
I have edited many columns in the same way from different tables, when I search in the specific column it returns nothing, because related text is not in the query table and I cannot join so many tables to get the result while searching.
Simplest solution i got
In your script just cahnge a single line serverSide: true to serverSide: false,
<script>
$.fn.dataTable.ext.errMode = 'none';
var tableObj;
$(document).ready(function(){
// debugger;
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
tableObj = $('{{ $class_name }}').DataTable({
searchable: true,
processing: true,
serverSide: false,
"aaSorting": [],
cache: true,
type: 'GET',
ajax: '{{ $routeValue }}',
#if(isset($table_columns))
columns: {!!$setData!!}
#endif
initComplete: function () {
this.api().columns().every(function () {
var column = this;
var input = document.createElement("input");
$(input).appendTo($(column.header()))
.on('keyup', function () {
column.search($(this).val(), false, false, true).draw();
});
});
}
});
$('.datatable').find('select.form-control').removeClass('form-control input-sm').addClass('full-width').attr('data-init-plugin','select2');
});
// console.log("it is working");
</script>
this will change the server side searching into client-side.
search from the content not from the datatable.
How silly i was mistaking
I'm trying to make this code to work but it look I'm doing something wrong when passing the two variables with ajax, please help, here is the code, basically is a drag and drop code to move items between boxes and organize inside each box.
<script type="text/javascript">
$(document).ready(function() {
// Example 1.3: Sortable and connectable lists with visual helper
$('#sortable-div .sortable-list').sortable({
connectWith: '#sortable-div .sortable-list',
placeholder: 'placeholder',
delay: 150,
stop: function() {
var selectedData = new Array();
$('.sortable-list>li').each(function() {
selectedData.push([$(this).attr("id"), $(this).attr("pagenum")])
});
updateOrder(selectedData);
}
});
});
function updateOrder(data) {
$.ajax({
url: "ajaxPro.php",
type: 'post',
data: {
position: data,
page: data
},
success: function() {
/* alert('your change successfully saved');*/
}
})
}
</script>
You can make it using this way:
$('.spremiUredivanje').click(function(){
ai = document.getElementById('ai_mjerila_edit').value;
broj_mjerila = document.getElementById('broj_mjerila_edit').value;
adresa = document.getElementById('adresa_edit').value;
stanje = document.getElementById('stanje_edit').value;
$( "#datum_edit" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
datum = document.getElementById('datum_edit').value;
operater = document.getElementById('operater_edit').value;
$.ajax({
url: 'test.php',
type: 'POST',
data: {
post1: broj_mjerila, post2: adresa, post3:stanje, post4: datum, post5: operater, post6:ai
},
beforeSend: function(){
$('#loaderEdit').show();
},
So your php file should look like this:
$broj_mjerila = $_POST['post1'];
$adresa = $_POST['post2'];
$stanje = $_POST['post3'];
$datum = $_POST['post4'];
$operater = $_POST['post5'];
$ai = $_POST['post6'];
To control your response use success inside ajax call:
success: function(response) {
if(response == 1) {
//alert("success!");
$('#editUspjesan').show();
$('#loaderEdit').hide();...
Can you explain your requirement clear. Are you trying to get page number and id in 2 separate array?
// If page no and id need to be in separate array
var position = [], pages = [];
$('.sortable-list>li').each(function() {
position.push($(this).attr("id"));
pages.push($(this).attr("pagenum"));
});
updateOrder(position, pages);
function updateOrder(position, page) {
$.ajax({
url: "ajaxPro.php",
type: 'post',
data: {
position: position,
page: page
},
success: function() {
/* alert('your change successfully saved');*/
}
})
}
// If page no and id can be combined use objects
var selectedData = [];
$('.sortable-list>li').each(function() {
selectedData.push({id: $(this).attr("id"), page: $(this).attr("pagenum")})
});
function updateOrder(data) {
$.ajax({
url: "ajaxPro.php",
type: 'post',
data: {
position: data
},
success: function() {
/* alert('your change successfully saved');*/
}
})
}
<script type="text/javascript">
$(document).ready(function() {
// Example 1.3: Sortable and connectable lists with visual helper
$('#sortable-div .sortable-list').sortable({
connectWith: '#sortable-div .sortable-list',
placeholder: 'placeholder',
delay: 150,
stop: function() {
var selectedData = new Array();
$('.sortable-list>li').each(function() {
selectedData.push([$(this).attr("id"), $(this).attr("pagenum")])
});
updateOrder(selectedData);
}
});
});
function updateOrder(data) {
$.ajax({
url: "ajaxPro.php",
type: 'post',
data: {
position: data.id,
page: data.pagenum
},
dataType:'json',
success: function() {
/* alert('your change successfully saved');*/
}
})
}
</script>
Let's try this one
I m trying to figure it out that is it possible to make the json data fetched dynamically from a database with the help of php and mysql and can be plotted with highcharts that too dynamic auto updating? Any help would be appreciated.
following the code i have tried and is not working properly and want to implement to the the website for 10 lines.
<HTML>
<HEAD>
<TITLE>highchart example</TITLE>
<script type="text/javascript"src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<script type="text/javascript">
var chart;
function requestData() {
$.ajax({
url: 'live-server-data.php',
success: function(point) {
var series = chart.series[0],
shift = series.data.length > 20; // shift if the series is
// longer than 2
// add the point
chart.series[0].addPoint(point, true, shift);
// call it again after one second
setTimeout(requestData1, 1000);
},
cache: false,
});
}
function requestData1() {
$.ajax({
url: 'live-server-data.php',
success: function(point) {
var series2 = chart.series[1],
shift = series2.data.length > 20; // shift if the series is
// longer than 20
// add the point
chart.series[1].addPoint(point, true, shift);
// call it again after one second
setTimeout(requestData, 1000);
},
cache: false,
});
}
$(function () {
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
defaultSeriesType: 'spline',
events: {
load: requestData
}
},
title: {
text: 'Live random data'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150,
maxZoom: 20 * 1000
},
yAxis:
{
minPadding: 0.2,
maxPadding: 0.2,
title: {
text: '',
margin: 80
}
},
series: [
{
name: 'Random data',
data: []
},
{
name: ' hahaha',
data: []
}
],
});
});
});
</script>
</HEAD>
<BODY>
<div id="container"
style="min-width: 728px; height: 400px; margin: 0 auto"></div>
</BODY>
</HTML>
*** the live-server-data.php is as followed:
<?php
// Set the JSON header
header("Content-type: text/json");
// The x value is the current JavaScript time, which is the Unix time multiplied
// by 1000.
$x = time() * 1000;
// The y value is a random number
$y = rand(48,52);
// Create a PHP array and echo it as JSON
$ret = array($x, $y);
echo json_encode($ret);
?>
You can try with
var options = {
chart: {
renderTo: 'chart',
},
credits: {
enabled: false
},
title: {
text: 'Impression/Click Overview',
x: -20
},
xAxis: {
categories: [{}]
},
tooltip: {
formatter: function() {
var s = '<b>'+ this.x +'</b>';
$.each(this.points, function(i, point) {
s += '<br/>'+point.series.name+': '+point.y;
});
return s;
},
shared: true
},
series: [{},{}]
};
$.ajax({
url: "json.php",
data: 'show=impression',
type:'post',
dataType: "json",
success: function(data){
options.xAxis.categories = data.categories;
options.series[0].name = 'Impression';
options.series[0].data = data.impression;
options.series[1].name = 'Click';
options.series[1].data = data.clicks;
var chart = new Highcharts.Chart(options);
}
});
The highcharts website has some useful articles about working with dynamic data. That is probably the best place to start.
http://www.highcharts.com/docs/working-with-data/preprocessing-live-data
http://www.highcharts.com/docs/working-with-data/preprocessing-data-from-a-database
Try something out, and if you have trouble, come back here with a more specific question showing what you have tried. As it stands, your question is too broad, and will probably get closed.
An ajax request for updating data looks something like:
function requestData() {
$.ajax({
url: 'live-server-data.php',
success: function(point) {
var series = chart.series[0],
shift = series.data.length > 20; // shift if the series is // longer than 20
// add the point
chart.series[0].addPoint(point, true, shift);
// call it again after one second
setTimeout(requestData, 1000);
},
cache: false
});
}
Update:
I tried and spent alot of my time fixing the issue, and at last problem solved.
But initially Many Thanks to OnaBai and to my colleague who helped to come this far.
Now i am stuck here.
I type username and it show display on dropdown and after pressing TAB or ENTER it show the result in grid.
The result is only shown in grid if it is from page "1", but if it is from page "2" or any other further page the result is not shown.
Here is how it is working:
but when if i search for other user which is not on page 1 then it dont show display the other user in grid. instead i get empty grid.
FireBug screenShots:
Here is my Updated Code after i did some more changes in the code.:
<?php
/*foreach($users_list_data->result() as $row){
echo $row->Username."<br />";
}*/
?>
<div id="grid"></div>
<div id="details" />
<div class="second_column_content_container">
</div>
<script>
function create_user() {
var entryform = $("#insert_user_info");
$.ajax({
type : 'POST',
url : '<?php echo base_url(); ?>/index.php/user_management/manage_users/createUser',
data : entryform.serialize(),
success : function(response) {
$(".second_column").html(response);
}
});
}
function create_user_form() {
$.ajax({
type : 'POST',
url : '<?php echo base_url(); ?>/index.php/user_management/manage_users/load_user_form',
success : function(response) {
$(".second_column").html(response);
}
});
}
function onChange(arg) {
var selected = "";
var grid = this;
grid.select().each(function() {
var dataItem = grid.dataItem($(this));
selected = dataItem.Username;
});
$.ajax({
type: "POST",
url: "<?php echo base_url()?>index.php/user_management/manage_users/get_user_groups/"+selected,
beforeSend: function(){
$("#pre_image").attr("src","http://localhost/zorkif_new/images/pre.gif");
},
success: function(output_string) {
$('.data_column_a').html(output_string);
}
});
}
var wnd, detailsTemplate;
$(document).ready(function(){
var serverBaseUrl = "<?php echo base_url(); ?>";
$("#grid").kendoGrid({
dataSource:{
serverPaging: true,
transport: {
read: serverBaseUrl + "index.php/user_management/manage_users/list_view/",
update: {
url: serverBaseUrl + "index.php/user_management/manage_users/userUpdate/",
type: "POST"
}
// destroy: {
// url: serverBaseUrl + "index.php/user_management/manage_users/userDelete/",
// dataType: "jsonp"
// }
//update: "<?php echo base_url() ?>index.php/user_management/manage_users/list_view/"
},
error: function(e) {
alert(e.responseText);
},
schema:{
data: "data",
total: "total",
model: {
id: "UserID",
fields: {
FirstName: { editable: true },
LastName: { validation: { required: true} },
MiddleNames:{validation:{required:true}}
}
}
},
pageSize:5
},
toolbar: kendo.template($("#toolbarTemplate").html()),
scrollable: true,
selectable: "row",
sortable: true,
filterable: true,
pageable: {
input: true,
numeric: false
},
columns: [
{
field: "UserID",
hidden:true
},
{
field: "Username",
title:"Username"
},
{ field: "FirstName",
title:"First Name"
},
{field:"MiddleNames"},
{field:"LastName"},
{field:"City"},
{field:"Email"},
//{field:"Actions"},
//{command: { text: "Delete", click: showDetails }, title: " ", width: "140px"},
{command: { text: "Details", click: redirectToPage }, title: " ", width: "140px" },
{ command: { text: "Edit", click: redirectToEditPage }, title: " ", width: "140px" }
],
change: onChange,
editable: "popup"
});
$("#users").kendoAutoComplete({
minLength: 3,
dataTextField: "Username",
dataSource: {
serverFiltering: true,
transport: {
read: {
type: "GET",
dataType: "json",
contentType:'application/json; charset=utf-8',
url: serverBaseUrl + "index.php/user_management/manage_users/search_user/",
data: function (arg){
//alert(arg);
//alert({Username:autocompleteUsers.data("kendoAutoComplete").value});
return {Username : $("#users").data("kendoAutoComplete").value()};
//return $("#users").data("kendoAutoComplete").value();
}
}
}
},
change: onChangeAutoComplete
});
function onChangeAutoComplete(){
var value = this.value();
var grid = $('#grid');
if (value) {
grid.data("kendoGrid").dataSource.filter({ field: "Username", operator: "Contains", value: value });
} else {
grid.data("kendoGrid").dataSource.filter({});
}
}
/*$("#users").kendoAutoComplete({
minLength: 3,
dataTextField: "Title",
//JSON property name to use
dataSource: {
pageSize: 10,
//Limits result set
transport: {
read: {
url: "/echo/json/",
//using jsfiddle echo service to simulate JSON endpoint
dataType: "json",
type: "POST",
data: {
// /echo/json/ echoes the JSON which you pass as an argument
json: JSON.stringify([
{
"Title": "Doctor Who: The Trial of a Time Lord"},
{
"Title": "Doctor Who: The Key to Time"},
{
"Title": "Doctor Who: The Time Meddler"},
{
"Title": "Doctor Who: The End of Time"}
])
}
}
}
}
});*/
/*change: function () {
var value = this.value();
if (value) {
grid.data("kendoGrid").dataSource.filter({ field: "UserID", operator: "eq", value: value });
} else {
grid.data("kendoGrid").dataSource.filter({});
}
}
});*/
/*$("#users").blur(function() {
var data = $(this).data("kendoAutoComplete").dataSource._data,
nbData = data.length,
found = false;
for(var iData = 0; iData < nbData; iData++) {
if(this.value === data[iData].Title)
found = true;
}
console.log(found);
});*/
wnd = $("#details").kendoWindow({
title: "Customer Details",
modal: true,
visible: false,
resizable: false,
width: 300
}).data("kendoWindow");
detailsTemplate = kendo.template($("#template").html());
});
function redirectToPage(e){
e.preventDefault();
var row = $(e.target).closest("tr");
var item = $("#grid").data("kendoGrid").dataItem(row);
$.ajax({
type: "POST",
url: "<?php echo base_url().'index.php/user_management/manage_users/ViewProfile/'?>"+JSON.parse(item.UserID),
success: function(output_string){
$('.second_column_content_container').html(output_string);
//$('.second_column_content_container').innerHTML("hello");
//alert(output_string);
},
error: function(data){
alert("error");
}
});
}
function redirectToEditPage(e){
e.preventDefault();
var row = $(e.target).closest("tr");
var item = $("#grid").data("kendoGrid").dataItem(row);
$.ajax({
type: "POST",
url: "<?php echo base_url().'index.php/user_management/manage_users/edit_user/'?>"+JSON.parse(item.UserID),
success: function(output_string){
$('.second_column_content_container').html(output_string);
//$('.second_column_content_container').innerHTML("hello");
//alert(output_string);
},
error: function(data){
alert("error");
}
});
}
//show details on a popup
function showDetailsPopup(e) {
e.preventDefault();
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
wnd.content(detailsTemplate(dataItem));
wnd.center().open();
}
//This will redirect to Next Page
function showDetails(e) {
e.preventDefault();
var row = $(e.target).closest("tr");
var item = $("#grid").data("kendoGrid").dataItem(row);
$.ajax({
type: "POST",
url: "<?php echo base_url().'index.php/user_management/manage_users/list_view/'?>"+JSON.parse(item.UserID),
success: function(data){
alert("done");
//$('.second_column_content_container').html(output_string);
//$('.second_column_content_container').innerHTML("hello");
//alert(output_string);
},
error: function(data){
alert("error");
}
});
//var grid = $("#grid").data("kendoGrid");
//alert(JSON.parse(item.UserID));
//window.location.href="http://www.google.com/";
}
</script>
<script type="text/x-kendo-template" id="template">
<div id="details-container">
<h2>#= FirstName #</h2>
<h2>City: #= City # </h2>
</div>
</script>
<script type="text/x-kendo-template" id="toolbarTemplate">
<div class="toolbar">
<label class="category-label" for="users">Search Users: </label>
<input type="text" id="users" style="width: 250px;" />
</div>
</script>
<div class="data_column_a">
<img src="" id="pre_image" >
</div>
Now how to solve this very extremely difficult problem O_o??
Update:
This Username is on Page 2 of the Grid as can be seen in ScreenShot.
But during Search, it sends the headers of page 1 when i search for username that is other than of page 1.
Banging my head to walls, How to Solve ?
The problem seems to be related to you autocomplete definition that is not sending any Username argument on read. Try defining transport.read as:
transport : {
read : {
url : "search_user.php",
data: function (arg) {
return {Username : autocompleteUsers.data("kendoAutoComplete").value()};
}
},
dataType: "json",
type : "POST"
},
EDIT: For applying selected value on autocomplete as filtering condition for the grid. You should do:
var autocompleteUsers = $("#users").kendoAutoComplete({
dataTextField: "Username",
dataSource : {
severFiltering: true,
transport : {
read : {
url : "search_user.php",
data: function (arg) {
return {Username: autocompleteUsers.data("kendoAutoComplete").value()};
}
},
dataType: "json",
type : "POST"
}
},
change : function () {
var username = autocompleteUsers.data("kendoAutoComplete").value();
var filter = {
logic : "and",
filters: [
{
ignoreCase: true,
field : "Username",
value : username,
operator : "startswith"
}
]
};
$("#grid").data("kendoGrid").dataSource.filter(filter);
}
});
I'm a beginner with php and fullcalendar.I need to update the calendar with the user input value ($('#name')). But it doesn´t work.
I have this code.
$(document).ready(function() {
var UsrAux;
$('#name').blur(function(){
UsrAux = $('#name').val() // <-- This is the input
});
$('#calendar').fullCalendar({
draggable: true,
height: 400,
cache: true,
eventSources: [
// your event source
{
url: 'CalendarServer.php',
type: 'POST',
data: {
uno: 'Something',
UsrCdg: UsrAux
},
error: function() {
alert('error!');
},
color: '#e2ebef', // a non-ajax option
textColor: 'black' // a non-ajax option
}
]
});
});
Any help would be greatly appreciated!
The blur event function should be defined before the fullCalendar as it gets the data (the user input) you need.
Hi this is the solution.
$(document).ready(function(){
var UsrAux;
UsrAux=$('#name').val();
$('#name').blur(function(){
UsrAux=$('#name').val();
var source = {
url: 'CalendarServer.php',
type: 'POST',
data: { // Parms
uno: 'Somenthing',
UsrCdg: UsrAux
},
error: function() {
alert('error!');
},
color: '#e2ebef', // a non-ajax option
textColor: 'black' // a non-ajax option
};
$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('addEventSource', source);
});
$('#calendar').fullCalendar({
draggable: true,
height: 400,
cache: true,
eventSources: [
// your event source
{
url: 'CalendarServer.php',
type: 'POST',
data: { // Parms
uno: 'something',
UsrCdg: $('#name').val()
},
error: function() {
alert('error!');
},
color: '#e2ebef', // a non-ajax option
textColor: 'black' // a non-ajax option
}
]
});
});