$('#example').DataTable({
searchBuilder: {
depthLimit: 1,
conditions: {
string: {
'=': null
}
}
},
dom: 'Qfrtip'
});
In this scenario , '=' equals condition was removed for the string type data.
But when using popup SearchBuilder it's not working.
This is the way to do this. SearchBuilder
Here is the code
<script>
$(document).ready(function () {
$(document).ready(function () {
$('#example').DataTable({
language: {
searchBuilder: {
button: {
0: 'Filter',
1: 'Filter (one applied)',
_: 'Filter (%d)'
}
}
},
buttons: [
{
extend: 'searchBuilder',
config: {
depthLimit: 1,
conditions: {
string: {
'=': null,
'!=': null
},
num: {
'=': null,
'!=': null
},
},
}
}
],
dom: 'Bfrtip'
});
});
});
</script>
Here the language option was used to change the name of the button. and other customizations are inside the buttons braces. Replace the dom attributes like below to align the table properly.
dom: "<'row'<'col-sm-12 col-md-6'B><'col-sm-12 col-md-6'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
Related
I want to know how i can add jquery validation for not equal values in two input textbox. I have tried this Example but its not working for me.
Jquery Code:
$.validator.addMethod("notEqual", function (value, element, param) {
return this.optional(element) || value != param;
}, "cannot be same as oldpassword");
$("#frmAddEdit").validate({
rules: {
"txtoldpassword": { required: true },
"txtnpassword": { required: true, notEqual:"#txtoldpassword" },
},
messages: {
"txtoldpassword": { required: "old Password is required" },
"txtnpassword": { required: "New Password is required" },
},
submitHandler: function (form) {
ChangeUserPassword();
return false;
}
});
When i put alert on validation method param shows the same value (i.e. #txtoldpassword) and when i put like this notEqual: $("#txtoldpassword").val() param becomes ""(blank)
Please help me on this.
I just changed the way of passing value of textbox for notEqual and it worked for me.
JQuery Code :
$("#frmAddEdit").validate({
rules: {
"txtoldpassword": { required: true, noSpace: true },
"txtnpassword": {
required: true, noSpace: true, notEqual: function () { return $("#txtoldpassword").val() },
}
},
messages: {
"txtoldpassword": { required: "old Password is required" },
"txtnpassword": { required: "New Password is required" },
},
submitHandler: function (form) {
ChangeUserPassword();
return false;
}
});
I am using a Kendo UI dataSource to bind KendoUIScheduler through SignalR. How can I pass parameters to the read operation of the dataSource with SignalR bindings?
I am using the following code:
var hub = $.connection.schedulerHub;
var hubStart = $.connection.hub.start();
$('#scheduler').kendoScheduler({
mobile: true,
height: 600,
views: [
'day',
'week',
'month',
'agenda',
{ type: 'timeline', selected: true }
],
timezone: 'Etc/UTC',
dataSource: {
type: "signalr",
push: function (e) {
alert(e.type);
},
autoSync: true,
transport: {
signalr: {
promise: hubStart,
hub: hub,
server: {
read:"read",
update: "update",
destroy: "destroy",
create: "create"
},
client: {
read:"read",
update: "update",
destroy: "destroy",
create: "create"
}
}
},
schema: {
model: {
id: 'SchedulerID',
fields: {
SchedulerID: { type: 'number', from: 'SchedulerID' },
start: { type: 'date', from: 'Start' },
end: { type: 'date', from: 'End' },
startTimezone: { from: "StartTimezone" },
endTimezone: { from: "EndTimezone" },
Title: { from: 'Title' },
isAllDay: { type: 'boolean', from: 'IsAllDay' },
recurrenceId: { from: "RecurrenceId" },
recurrenceException: { from: "RecurrenceException" },
recurrenceRule: { from: "RecurrenceRule" },
Users: { nullable: true, from: 'Users' },
},
}
}
},
group: {
resources: ['Users'],
orientation: 'vertical'
},
resources: [
{
field: 'Users',
name: 'Users',
dataSource: Users,
multiple: false,
title: 'Users'
}
]
});
I realize this question is old, but I was trying to find this same answer and didn't find any clear solutions. I did find some hints in other threads that led me to a solution although I'm sure there are better ones (I wasn't able to figure out how to send the parameters separately - only as one object).
In your datasource, use the parameterMap function to put in whatever custom parameters you want. When binding to WCF (commented code) you can separate the parameters for the call but I couldn't get that to work with the SignalR implementation.
type: "signalr",
transport: {
parameterMap: function (data, type) {
switch (type) {
case "read":
{
// this works
var request = {};
var chkunsub = $('#chkunsubscribed').is(':checked');
request.unsubscribed = chkunsub;
request.oKendo = data;
return request;
// Does not work (separating parameters)
//return {
// unsubscribed: chkunsub,
// oKendo: data
//};
}
// Does not work either (separating parameters)
//return kendo.stringify({
// unsubscribed: chkunsub ? 1 : 0,
// oKendo: data
//});
}
},
Note that the "data" variable contains the filter, paging, grouping, etc. (I'm binding to a grid but I would think it's the same for scheduler).
Then on the server side in your hub, you just need to mirror the class structure like this (my CKendoGridOptions class has all of the properties from the API such as page, skip, filter, etc).
Public Class EventRequestData
Public Property unsubscribed As Boolean
Public Property oKendo As CKendoGridOptions
End Class
' This works
Public Function read(data As EventRequestData) As OrmedReturnData
Dim oReturn As New OrmedReturnData
If IsLoggingEnabled() Then
WriteToEventLog("Hub getevent_item called")
End If
Dim oToken As TokenHelper.TokenData = TokenHelper.ValidateToken(New Guid(Context.Request.Cookies("token").Value))
If oToken.TokenOK = False Then
oReturn.Success = False
oReturn.ErrorMessage = ERROR_INVALID_TOKEN
Else
Dim oData As New EventItems
oReturn = oData.Getevent_items(data.unsubscribed, data.oKendo)
End If
Return oReturn
End Function
I hope this helps someone else who is trying to pass parameters to a read function using Kendo in jQuery and SignalR.
Hi I am struggling to display my jtable. It only displays when I step through the javascript with the debugger.
$("body").on("click", "#tabRole", function () {
document.getElementById("1").className = "inactive";
document.getElementById("2").className = "active";
$('#Admin-details').load('../Admin/ADRoleAdmin');
jTableRoles();
});
This method loads ADRoleAdmin as a partial view into a div. Then jTableRoles() should load the jtable into a div (jTableRoles) inside ADRoleAdmin:
var jTableRoles = function () {
$(function () {
debugger;
$('#jTableRoles').jtable({
paging: true,
pageSize: 20,
sorting: true,
title: 'Roles',
onRowEdit: function (event, data) {
UpdateRoleDetails(data.records.RoleId, data.records.RoleName);
},
actions: {
listAction: '../Admin/GetRoles',
updateAction: 'dummy'
},
toolbar: {
items: [{
icon: '../Content/images/Misc/Add icon.png',
text: 'Create New',
click: function () {
UpdateRoleDetails(0, '');
}
}]
},
fields: {
Id: {
key: true,
list: false
},
Name: {
title: 'Role name',
},
Description: {
title: 'Role description',
sorting: false
}
}
});
$('#jTableRoles').jtable('load');
});
}
Please tell me what I am doing wrong or what I can do different to make it work.
Looping through the steps takes extra time.
It looks like the load of ADRoleAdmin is not finished on the moment the jTable is loaded.
Try to start the jtable after a certain timeout to check.
Preferably load the ADRoleAdmin an on it's postback load the jTable
hello I have the following snippet of code.
Departments
<div>Users </div>
<div id="UserTableContainer"></div>
<script type="text/javascript">
var departmentChangeId = 1;
$(document).ready(function () {
$('#DepartmentTableContainer').jtable({
paging: true,
useBootstrap: true,
sorting: true,
selecting: true,
selectOnRowClick: true,
title: 'Departments',
actions: {
listAction: '/api/Department/GetDepartmentList',
createAction: '/api/Department/CreateDepartment',
updateAction: '/api/Department/EditDepartment',
deleteAction: '/api/Department/DeleteDepartment'
},
fields: {
ID: {
key: true,
list: false
},
TypeId: {
title: 'Department Type',
options: '/api/Department/GetDepartmentTypeList'
},
Label: {
title: 'Department'
},
},
//Register to selectionChanged event to hanlde events
selectionChanged: function () {
//Get all selected rows
var $selectedRows = $('#DepartmentTableContainer').jtable('selectedRows');
departmentChangeId = $selectedRows.data('record').ID;
//alert(departmentChangeId);
//
refresh();
}
}).jtable('load');
$('#UserTableContainer').jtable({
messages: ArabMessages, //Lozalize
paging: true,
useBootstrap: true,
sorting: true,
title: 'Employee',
actions: {
listAction: '/api/Users/GetEmployee?id=' + departmentChangeId,
updateAction: '/api/Users/EditEmployee'
},
fields: {
Id: {
key: true,
list: false
},
DepId: {
title: ' Department',
options: '/api/Department/GetDepartmentTypeList'
},
LastName: {
title: 'Name'
},
}
});
$('#UserTableContainer').jtable('load');
});
and these are the two version I use for the refresh function
first
function refresh() {
$('#UserTableContainer').jtable('reload');
}
the second
function refresh() {
$.post("/api/Users/GetEmployee", "id=" + departmentChangeId,
function (results) {
$('#UserTableContainer').jtable('reload');
}
, "json");
}
unfortunately both of them dont work
instead of when I use debugging mode I see that the /api/Users/GetEmployee is visited in both case
please try using below code in refresh function
$('#UserTableContainer').jtable('load');
I am using the jQuery validator to validate a jQuery multiselect dropdownlist but it does not validate, my functions are bellow:
These functions are created from my code behind and registered on the page with the ScriptManager.RegisterClientScriptBlock.
I put the following directly on the aspx page and it then validates the multiselect, but as soon as I do it from the code behind and register the script, all validators besides the multiselect works.
$.validator.addMethod('notNone', function(value, element) {
return (value != '-1');
}, 'Please select an option.');
var $callback = $("#callback");
$(document).ready(function () {
$("#<%=example.ClientID%>").multiselect(
{
show: "fade",
hide: "fade",
click: function (event, ui) {
$callback.text(ui.text + ' ' + (ui.checked ? 'checked' : 'unchecked'));
},
});
});
$("#form1").validate({
rules: {
<%=example.UniqueID %>: {
notNone: true,
},
<%=txtPassword.UniqueID %>: {
//minlength: 5,
//required: true
},
<%=TextIdea.UniqueID %>: {
//minlength: 5,
//required: true
},
<%=ddlTest.UniqueID %>: {
//notNone: true
},
redemption : {
redemption : false
},
redemption: {
redemptionEnd : false
},
},
ignore: ':hidden:not("#<%=example.ClientID %>")',
messages: {
<%=example.UniqueID %>:{
notNone: "Plaese select something",
},
<%=txtPassword.UniqueID %>:{
required: "Plaese enter your password",
minlength: "Password must be atleaet of 5 characters"
},
<%=TextIdea.UniqueID %>:{
required: "Plaese enter your Ideas",
minlength: "Password must be atleaet of 5 characters"
},
}
});
My markup:
<select id="example" name="example" runat="server">
</select>
Am I doing something wrong? Please help guys.
Thanks in advance.
Okay, after 2 days I finally figured out what was going on, turns out the controls that use the jQuery multiSelect, their UniqueID gets appended with _multiSelect and the ClientID gets appended with $multiSelect.
Added those strings when getting the Client/UniqueID and it works.