Bootstrap Table remove row if column have no data - javascript

Hi have this WCF Service and consuming that is working. My problem is column 7 may be empty, so in the client side i want to remove all rows that have column 7 empty. Any help will be welcome.
function GetPedidosAll(muser) {
jQuery.ajax({
cache: false,
type: "GET",
url: "/_vti_bin/XP/Requests.svc/GetPedidosListAll/" + muser +
"/" + $("#sel_state").val() + "/" + $("#sel_project").val(),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
$("#lista_pedidos").bootstrapTable({
data: data
});
},
error: function (jqXhr, status) {
$("#img_Progress").hide();
MessPopups("e", status.message);
}
});}
Thank You,
JL

success: function (data) {
data = jQuery.grep(data, function (a) {
return a.Permissao !== "";
});
$("#lista_pedidos").bootstrapTable({
data: data
});
}

Related

How to simplfy the passing of parameter

I have these method in c# which requires 3 parameters
public void Delete_AgentTools(int ID,int UAM,int mode)
{
some code etc.
}
and I use javascript ajax to call this method and pass the parameter
function Delete_AgentTools(toolAccess, toolId, UAM) {
$.ajax({
type: "POST",
url: "IROA_StoredProcedures.asmx/Delete_AgentTools",
data: "{'toolAccess':'" + toolAccess + "', 'toolId':'" + toolId + "', 'UAM':'" + UAM + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success:function()
{
alert("Tool has been successfully delete");
},
error: function (XMLHttpRequest)
{
alert("error in Delete_AgentTools()");
console.log(XMLHttpRequest);
}
});
}
you see for me I want to simpilfy on how I pass the parameter in javascript. Is it possible to pass it as an object to the c# or simplify the passing of parameters in javascript
You can convert a js object as a JSON using JSON.stringify
var data = {};
data.toolAccess = value1;
data.toolId = value2;
data.UAM = value3;
$.ajax({
type: "POST",
url: "IROA_StoredProcedures.asmx/Delete_AgentTools",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
success:function()
{
alert("Tool has been successfully delete");
},
error: function (XMLHttpRequest)
{
alert("error in Delete_AgentTools()");
console.log(XMLHttpRequest);
}
});
function Delete_AgentTools(toolAccess, toolId, UAM) {
var data = {};
data.mode = toolAccess;
data.ID = toolId;
data.UAM = UAM;
$.ajax({
type: "POST",
url: "IROA_StoredProcedures.asmx/Delete_AgentTools",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
success:function()
{
alert("Tool has been successfully delete");
},
error: function (XMLHttpRequest)
{
alert("error in Delete_AgentTools()");
console.log(XMLHttpRequest);
}
});
No need to change in your C# code.

Need assistance with understanding .each() and issue with duplicate in Ajax GET

I have an ajax code as below :
<script>
$(document).ready(function () {
EmployeeStates("Available", 1, 15);
});
function EmployeeStates(state, pageNumber, pageSize) {
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
url: "http://localhost:58102/api/EmployeeState?state=" + state + "&pageNumber=" + pageNumber + "&pageSize=" + pageSize,
//data: JSON.stringify({ "state": state,"pageNumber":pageNumber,"pageSize":pageSize }),
dataType: "json",
success: function (data) {
$.each(data, function (index, emp) {
$("#ReservationDesignation").append(emp.employee.designation.designationName);
});
},
fail: function (error) {
Console.Log(error);
}
})
}
</script>
While assigning the Designation name (emp.employee.designation.designationName) to #ReservationDesignation, I am getting a duplicate.
ie, ArchitectArchitect. The actual result should be Architect.
I am not familiar with .each() function.
Can anyone help me to remove the duplicate from the result?
Thank You.

How to increment HTML h4 tag in AJAX call? I am getting h41, h42 values when I debug

<script>
var pageUrl = "http://localhost:12152/Product.aspx";
window.onload = function () {
var ncount = 0;
ncount++;
$("#callproceed").click(function () {
alert("working");
$.ajax({
type: "POST",
url: pageUrl + '/AddProceed',
data: '{subPoints:' + parseInt($("#h4+ncount").html()) + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
dataFilter: function (data) { return data; },
success: function (response) {
alert(response.d);
} ,
failure: function (response) {
alert(response.d);
}
});
});
};
</script>
I am making an AJAX call to fetch all dynamic data in HTML tag but only I am getting 1 value.
Are you trying to store the count inside #h4? Try this:
$("#h4").html(ncount++)

Ajax Response is not defeined

I am quite green when it comes to AJAX and am trying to get an email address from an ASP.Net code behind function
When using the below code I am getting the error as per the title of this issue.
This is the code I am using
$('.txtRequester').focusout(function () {
console.log("textBox has lost focus");
function ShowCurrentTime() {
$.ajax({
type: "POST",
url: "Default.aspx/FindEmailAddress",
data: '{id: "' + $("txtRequester").val + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
});
which is an adaptation of the code from this site.
ASP.Net Snippets
When changing the line
success: OnSuccess to success: alert(response) or success: alert(data)
I get the error up, but if I use success: alert("ok") I get the message saying ok so I suspect that I am getting into the function as below.
<System.Web.Services.WebMethod()> _
Public Shared Function FindEmailAddress(ByVal id As String) As String
Dim response As String = GetEmail(id)
Return response
End Function
I would be extremely grateful if someone to help me and let me know where I am going wrong on this one.
thanks
I think you have can check the state of failure by using this code below as I think there is wrong syntax used by you.
$('.txtRequester').focusout(function () {
console.log("textBox has lost focus");
function ShowCurrentTime() {
$.ajax({
type: "POST",
url: "Default.aspx/FindEmailAddress",
data: JSON.stringify({id: ' + $(".txtRequester").val() + ' }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data, status, header){
console.log(data);
},
error: function (response) {
alert(response.d);
}
});
}
});
then definitely you will get error response, if your success won't hit.
You have not called the function thats why its never get called.
$('.txtRequester').focusout(function () {
console.log("textBox has lost focus");
ShowCurrentTime();
});
function ShowCurrentTime() {
$.ajax({
type: "POST",
url: "Default.aspx/FindEmailAddress",
data: '{id: "' + $("txtRequester").val() + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
Onsuccess(response);
},
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
This will help :)
use ajax directly ,
$('.txtRequester').focusout(function () {
console.log("textBox has lost focus");
var cond = $(".txtRequester").val();
$.ajax({
type: "POST",
url: "Default.aspx/FindEmailAddress",
data: {id:cond},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response){
alert(response.d);
},
failure: function (response) {
alert(response.d);
}
});
});
Change $('.txtRequester') to $('#txtRequester')
and
Change $("txtRequester").val to $('#txtRequester').val()

How to update jqx grid using jquery

$.ajax({
url: "RequestHandler?usercommand=showcriticaldatezone&useraction=ShowUserPreferenceDashbord_frm&subCommand=criticaldatezone",
type: 'POST',
dataType: 'json',
data: dateText,
contentType: 'application/json',
async:'false',
cache:'false',
success: function (data) {
var parsedJSON = JSON.parse(data);
var tempdate;
alert("parse json - "+parsedJSON.length);
js= [];
for (var i=0;i<parsedJSON.length;i++) {
alert(" critical date is -:"+parsedJSON[i].CriticalDate);
js.push(parsedJSON[i].CriticalDate);
//tempdate='{"Date":['+'"'+ parsedJSON[i].CriticalDate + '"' + ']}';
}
tempdate='{"Date":'+JSON.stringify(js)+'}';
alert("stringify is -:"+tempdate);
selectedDate=tempdate;
jqxgriddata=data;
$(this).datepicker("refresh");
jQuery("#myGrid").setGridParam({ 'data': data}).trigger("reloadGrid");
alert('sucess!');
},
error:function(data,status,er) {
alert("error: "+data+" status: "+status+" er:"+er);
}
});
i am using above code to refresh grid after server response but not success i am using jqx grid Server response is json array i am able to display grid at first time but not able to refresh it please help

Categories

Resources