jQuery UI Widgets › Forums › Grid › Refresh problem after insert, delete .
Tagged: #refresh #refreshtable #after #insert, angular grid, angular2 grid, bootstrap grid, javascript grid, jquery grid, jqwidgets grid, jqxgrid, typescript grid
This topic contains 1 reply, has 2 voices, and was last updated by Hristo 7 years, 10 months ago.
-
Author
-
Hi i have tried to refresh table after insert with all methods , can anyone help me ?
` <%@ Page Title=”” Language=”C#” MasterPageFile=”~/Conta.Master” AutoEventWireup=”true” CodeBehind=”TipSolicitari.aspx.cs” Inherits=”Conta.TipSolicitari1″ %>
<asp:Content ID=”Content1″ ContentPlaceHolderID=”head” runat=”server”>
</asp:Content><asp:Content ID=”Content2″ ContentPlaceHolderID=”MainContent” runat=”server”>
<link type=”text/css” href=”/jqwidgets/styles/jqx.base.css” rel=”stylesheet” />
<link type=”text/css” href=”/jqwidgets/styles/jqx.classic.css” rel=”stylesheet” />
<link type=”text/css” href=”/jqwidgets/styles/jqx.metro.css” rel=”stylesheet” />
<link type=”text/css” href=”/jqwidgets/styles/jqx.office.css” rel=”stylesheet” />
<link type=”text/css” href=”/jqwidgets/styles/jqx.energyblue.css” rel=”stylesheet” /><link type=”text/css” href=”/1.11.4/jquery-ui.min.css?” rel=”stylesheet” />
<%–<script type=”text/javascript” src=”/javascript/jquery-2.2.3.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqx-all.js”></script>
–%>
<script type=”text/javascript” src=”/javascript/jquery-1.11.1.min.js?”></script>
<script type=”text/javascript” src=”/1.11.4/jquery-ui.min.js?”></script>
<script type=”text/javascript” src=”/jqwidgets/jqx-all.js?”></script><script type=”text/javascript” src=”/jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxdropdownlist.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxmenu.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxgrid.filter.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxgrid.selection.js”></script><script type=”text/javascript” src=”/jqwidgets/jqxcheckbox.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxgrid.sort.js”></script>
<%– <script type=”text/javascript” src=”/jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxdata.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxbuttons.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxscrollbar.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxlistbox.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxdropdownlist.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxmenu.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxgrid.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxgrid.filter.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxgrid.sort.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxgrid.selection.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxpanel.js”></script>
<script type=”text/javascript” src=”/jqwidgets/globalization/globalize.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxcalendar.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxdatetimeinput.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxcheckbox.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxgrid.pager.js”></script>
<script type=”text/javascript” src=”/jqwidgets/jqxgrid.columnsresize.js”></script>–%><style type=”text/css”>
.no-close .ui-dialog-titlebar-close {
display: none;
}
div.ui-dialog {z-index:1000;}
div.ui-dialog-titlebar{display:none;}
/*ui-widget-header ui-corner-all ui-helper-clearfix ui-draggable-handle*/
/*div.ui-dialog {float: left; width: auto !important; display:none;}*/
</style><script type=”text/javascript”>
var bInit = 1;
var sUserName = “”;// function runADDbtn()
// {
// alert(“work”);
// }$(document).ready(function () {
// $(‘#addbutton’).click(function () {
// //$(“#jqxgrid”).jqxGrid(‘clearfilters’);
// alert(‘WORK1’);
// });/*$(“#pageHome”).click(function () {
window.location.replace(“Default.aspx”);
});*/
$(‘#delogare’).click(function () {
$(‘input[id$=btnLogout]’).click();
});
$(‘img[title=Setari]’).click(function () {
getUserForUpdateSettings($(this).parent().find(‘div’).attr(‘value’));
});
//#R Hide all errors$(‘#alertOldPassU’).hide();
$(‘#alertOldPassWrongU’).hide();
$(‘#alertUsernameU’).hide();
$(‘#alertPassU’).hide();
$(‘#alertConfirmPassU’).hide();
$(‘#alertEmail’).hide();});
var bInit = 1;
var sUserName = “”;
function closeIframeBind() {
//$(‘#somediv’).dialog(‘close’);
$(“#thedialog”).attr(‘src’, “about:blank”);
$(‘#somediv’).dialog(‘destroy’);
$(‘#jqxgrid’).jqxGrid(‘updatebounddata’);
return false;
}
function closeIframeNoBind() {
$(“#thedialog”).attr(‘src’, “about:blank”);
$(‘#somediv’).dialog(‘destroy’);
return false;
}
$(document).keypress(function (e) {
if (e.keyCode === 13) {
e.preventDefault();
return false;
}
});function buildQueryString(data) {
var str = ”;
for (var prop in data) {
if (data.hasOwnProperty(prop)) {
str += prop + ‘=’ + data[prop] + ‘&’;
}
}
$(‘#hidGridFormatedData’).val(formatedData);
return str.substr(0, str.length – 1);
}
var formatedData = ”;
var totalrecords = 0;//start
$(document).ready(function () {
document.title = ‘Tip Solicitari’;
sUserName = $(‘#’ + ‘<%=hdnLoginName.ClientID %>’).val();//add button bind
$(‘#btnRight’).click(function(e) {var selectedOpts = $(‘[id$=ListBox1] option:selected’);
if (selectedOpts.length == 0) {
alert(“Nu ati selectat nimic pentru a adauga.”);
e.preventDefault();
}$(“[id$=ListBox2]”).append($(selectedOpts).clone());
$(selectedOpts).remove();var deletedid=””;
for(var iIndex = 0;iIndex < $(selectedOpts).length;iIndex++){
deletedid= $(selectedOpts)[iIndex].value;var searchedstring = “;” + deletedid + “;”;
var bIsAlreadyInDB = false;
if($(“[id$=hdnRemUsers]”).val().indexOf(searchedstring) != -1 ){
$(“[id$=hdnRemUsers]”).val($(“[id$=hdnRemUsers]”).val().replace(deletedid + “;”,””));
bIsAlreadyInDB = true;
}if($(“[id$=hdnAddedUsers]”).val() == ”){
$(“[id$=hdnAddedUsers]”).val(“;”);
}
if(!bIsAlreadyInDB)
$(“[id$=hdnAddedUsers]”).val($(“[id$=hdnAddedUsers]”).val() +$(selectedOpts)[iIndex].value + “;” );
}e.preventDefault();
});
//—————————DubleClickEvent
$(“[id$=ListBox1]”).dblclick(function(e) {var selectedOpts = $(‘[id$=ListBox1] option:selected’);
if (selectedOpts.length == 0) {
alert(“Nu ati selectat nimic pentru a adauga.”);
e.preventDefault();
}$(“[id$=ListBox2]”).append($(selectedOpts).clone());
$(selectedOpts).remove();var deletedid=””;
for(var iIndex = 0;iIndex < $(selectedOpts).length;iIndex++){
deletedid= $(selectedOpts)[iIndex].value;var searchedstring = “;” + deletedid + “;”;
var bIsAlreadyInDB = false;
if($(“[id$=hdnRemUsers]”).val().indexOf(searchedstring) != -1 ){
$(“[id$=hdnRemUsers]”).val($(“[id$=hdnRemUsers]”).val().replace(deletedid + “;”,””));
bIsAlreadyInDB = true;
}if($(“[id$=hdnAddedUsers]”).val() == ”){
$(“[id$=hdnAddedUsers]”).val(“;”);
}
if(!bIsAlreadyInDB)
$(“[id$=hdnAddedUsers]”).val($(“[id$=hdnAddedUsers]”).val() +$(selectedOpts)[iIndex].value + “;” );
}e.preventDefault();
});
//————————————–//remove button bind
$(‘#btnLeft’).click(function(e) {
var selectedOpts = $(‘[id$=ListBox2] option:selected’);
if (selectedOpts.length == 0) {
alert(“Nu ati selectat nimic pentru a sterge.”);
e.preventDefault();
}
//hdnRemUsers
if($(“[id$=hdnRemUsers]”).val() == ”){
$(“[id$=hdnRemUsers]”).val(“;”);
}var addedid= “”;
for(var iIndex = 0;iIndex < $(selectedOpts).length;iIndex++){
addedid= $(selectedOpts)[iIndex].value;
var searchedstringtoadd = “;” + addedid + “;”;if($(“[id$=hdnAddedUsers]”).val().indexOf(searchedstringtoadd) != -1 ){
$(“[id$=hdnAddedUsers]”).val($(“[id$=hdnAddedUsers]”).val().replace(addedid + “;”,””));
}
$(“[id$=hdnRemUsers]”).val($(“[id$=hdnRemUsers]”).val() +$(selectedOpts)[iIndex].value + “;” );
$(“[id$=ListBox1]”).append($(selectedOpts).clone());
$(selectedOpts).remove();
}
e.preventDefault();
});//DubleClickEvent
$(“[id$=ListBox2]”).dblclick(function(e) {
var selectedOpts = $(‘[id$=ListBox2] option:selected’);
if (selectedOpts.length == 0) {
alert(“Nu ati selectat nimic pentru a sterge.”);
e.preventDefault();
}
//hdnRemUsers
if($(“[id$=hdnRemUsers]”).val() == ”){
$(“[id$=hdnRemUsers]”).val(“;”);
}var addedid= “”;
for(var iIndex = 0;iIndex < $(selectedOpts).length;iIndex++){
addedid= $(selectedOpts)[iIndex].value;
var searchedstringtoadd = “;” + addedid + “;”;if($(“[id$=hdnAddedUsers]”).val().indexOf(searchedstringtoadd) != -1 ){
$(“[id$=hdnAddedUsers]”).val($(“[id$=hdnAddedUsers]”).val().replace(addedid + “;”,””));
}
$(“[id$=hdnRemUsers]”).val($(“[id$=hdnRemUsers]”).val() +$(selectedOpts)[iIndex].value + “;” );
$(“[id$=ListBox1]”).append($(selectedOpts).clone());
$(selectedOpts).remove();
}
e.preventDefault();
});//—————————————————————————– ADD BUTTON———–
//add button bind
$(‘#btnRight1’).click(function(e) {var selectedOpts = $(‘[id$=ListBox3] option:selected’);
if (selectedOpts.length == 0) {
alert(“Nu ati selectat nimic pentru a adauga.”);
e.preventDefault();
}
$(“[id$=ListBox4]”).append($(selectedOpts).clone());
$(selectedOpts).remove();
var deletedid=””;
for(var iIndex = 0;iIndex < $(selectedOpts).length;iIndex++){
deletedid= $(selectedOpts)[iIndex].value;var searchedstring = “;” + deletedid + “;”;
var bIsAlreadyInDB = false;
if($(“[id$=hdnRemUsers]”).val().indexOf(searchedstring) != -1 ){
$(“[id$=hdnRemUsers]”).val($(“[id$=hdnRemUsers]”).val().replace(deletedid + “;”,””));
bIsAlreadyInDB = true;
}if($(“[id$=hdnAddedUsers]”).val() == ”){
$(“[id$=hdnAddedUsers]”).val(“;”);
}
if(!bIsAlreadyInDB)
$(“[id$=hdnAddedUsers]”).val($(“[id$=hdnAddedUsers]”).val() +$(selectedOpts)[iIndex].value + “;” );
}
e.preventDefault();
});
//——————DBCLICK SENDER
$(“[id$=ListBox3]”).dblclick(function(e) {var selectedOpts = $(‘[id$=ListBox3] option:selected’);
if (selectedOpts.length == 0) {
alert(“Nu ati selectat nimic pentru a adauga.”);
e.preventDefault();
}
$(“[id$=ListBox4]”).append($(selectedOpts).clone());
$(selectedOpts).remove();
var deletedid=””;
for(var iIndex = 0;iIndex < $(selectedOpts).length;iIndex++){
deletedid= $(selectedOpts)[iIndex].value;var searchedstring = “;” + deletedid + “;”;
var bIsAlreadyInDB = false;
if($(“[id$=hdnRemUsers]”).val().indexOf(searchedstring) != -1 ){
$(“[id$=hdnRemUsers]”).val($(“[id$=hdnRemUsers]”).val().replace(deletedid + “;”,””));
bIsAlreadyInDB = true;
}if($(“[id$=hdnAddedUsers]”).val() == ”){
$(“[id$=hdnAddedUsers]”).val(“;”);
}
if(!bIsAlreadyInDB)
$(“[id$=hdnAddedUsers]”).val($(“[id$=hdnAddedUsers]”).val() +$(selectedOpts)[iIndex].value + “;” );
}
e.preventDefault();
});
//—————————————–//remove button bind
$(‘#btnLeft2’).click(function(e) {
var selectedOpts = $(‘[id$=ListBox4] option:selected’);
if (selectedOpts.length == 0) {
alert(“Nu ati selectat nimic pentru a sterge.”);
e.preventDefault();
}
//hdnRemUsers
if($(“[id$=hdnRemUsers]”).val() == ”){
$(“[id$=hdnRemUsers]”).val(“;”);
}var addedid= “”;
for(var iIndex = 0;iIndex < $(selectedOpts).length;iIndex++){
addedid= $(selectedOpts)[iIndex].value;
var searchedstringtoadd = “;” + addedid + “;”;if($(“[id$=hdnAddedUsers]”).val().indexOf(searchedstringtoadd) != -1 ){
$(“[id$=hdnAddedUsers]”).val($(“[id$=hdnAddedUsers]”).val().replace(addedid + “;”,””));
}
$(“[id$=hdnRemUsers]”).val($(“[id$=hdnRemUsers]”).val() +$(selectedOpts)[iIndex].value + “;” );
$(“[id$=ListBox3]”).append($(selectedOpts).clone());
$(selectedOpts).remove();
}
e.preventDefault();
});
//——————–DBCLICK REMOVE
$(“[id$=ListBox4]”).dblclick(function(e) {
var selectedOpts = $(‘[id$=ListBox4] option:selected’);
if (selectedOpts.length == 0) {
alert(“Nu ati selectat nimic pentru a sterge.”);
e.preventDefault();
}
//hdnRemUsers
if($(“[id$=hdnRemUsers]”).val() == ”){
$(“[id$=hdnRemUsers]”).val(“;”);
}var addedid= “”;
for(var iIndex = 0;iIndex < $(selectedOpts).length;iIndex++){
addedid= $(selectedOpts)[iIndex].value;
var searchedstringtoadd = “;” + addedid + “;”;if($(“[id$=hdnAddedUsers]”).val().indexOf(searchedstringtoadd) != -1 ){
$(“[id$=hdnAddedUsers]”).val($(“[id$=hdnAddedUsers]”).val().replace(addedid + “;”,””));
}
$(“[id$=hdnRemUsers]”).val($(“[id$=hdnRemUsers]”).val() +$(selectedOpts)[iIndex].value + “;” );
$(“[id$=ListBox3]”).append($(selectedOpts).clone());
$(selectedOpts).remove();
}
e.preventDefault();
});
//——————————————-//—————————————————————————–END ADD BUTTON———–
//……………………………………………………..$.ajax({
type: “POST”,
url: ‘/api/TipSolicitari.asmx/GetCustomers?’+ “filterscount=0&groupscount=0&sortdatafield=Nume&sortorder=asc&pagenum=0&pagesize=1500&recordstartindex=0&recordendindex=10&bInit=1&sUserName=”,
pager: function (pagenum, pagesize, oldpagenum)
{
},
contentType: “application/json; charset=utf-8”,
// data: { bInit: bInit, sUserName: sUserName },
dataType: “json”,
success: function (data) {//………………………………………… bun
var source = {
datatype: “json”,
datafields: [
{ name: ‘ID’, type: ‘int’ },
{ name: ‘Nume’, type: ‘string’ },
{ name: ‘Responsabil’, type: ‘bool’ },
{ name: ‘Clasa’, type: ‘string’ }],
async: false,sort: function () {
source.data = { bInit: bInit, sUserName: sUserName };
if (bInit != ‘1’) {
$(“#jqxgrid”).jqxGrid(‘updatebounddata’, ‘sort’);
}
bInit++;
},
filter: function ()
{
source.data = { bInit: bInit, sUserName: sUserName };
if (bInit != ‘1’) {
$(“#jqxgrid”).jqxGrid(‘updatebounddata’, ‘filter’);
}
bInit++;
},
//beforeprocessing: function (data) {
var returnData = {};
data = data.d;
// totalrecords = data.count;
//returnData.totalrecords = data.count;
//returnData.records = data.data;
return returnData;
},//——————————————————————————————————————————————
addRow: function (ID, rowData, position, commit) {
var data = “insert=true&” + $.param(rowData);
//var data = “insert=true&rowID=”+rowID+”&”+$.param(rowData);
//var data = “insert=true&ID=228&Nume=test24&Responsabil=true&Clasa=test_Cl228”;
$.ajaxSetup({ async: false });
setTimeout(function () {
$.ajax({dataType: ‘json’,
url: ‘/api/TipSolicitari.asmx/TipSolicitari_Insert’,
cache: false,
data: data,
//type: “GET”,success: function (data, status, xhr) {
// update command is executed.
commit(true);
alert(commit(true));
alert(‘work’);
dataAdapter.dataBind();},
//
// ,
// error: function () {
// commit(false);
// alert(‘Does not work’);
// }
});
$(“#jqxgrid”).jqxGrid(‘updatebounddata’);
}, 500);
$.ajaxSetup({ async: true });
return false;
},
updateRow: function (rowID, rowData, commit) {
var data = “update=true&” + $.param(rowData);//+ “&sortdatafield=CompanyName&sortorder=asc&filterscount=0&pagenum=0&pagesize=10”
$.ajaxSetup({ async: false });
setTimeout(function () {
$.ajax({
dataType: ‘json’,
url: ‘/api/TipSolicitari.asmx/TipSolicitari_Update’,
cache: false,
data: data,
success: function (data, status, xhr) {
// update command is executed.
commit(true);
alert(commit(true));
dataAdapter.dataBind();}
});
}, 500);
$.ajaxSetup({ async: true });
return false;},
deleteRow: function (rowID, rowData, commit) {console.log(“Delete…….”);
var tipsolicitareID = $(“#jqxgrid”).jqxGrid(‘getrowdata’, rowID).ID;
var data = “request=deleteuser&ID=” + tipsolicitareID;
//”&sortdatafield=CompanyName&sortorder=asc&filterscount=0&pagenum=0&pagesize=10″
$.ajaxSetup({ async: false });
setTimeout(function () {
$.ajax({
dataType: ‘json’,
url: ‘/api/TipSolicitari.asmx/TipSolicitari_Delete’,
cache: false,
data: data,
// type: “post”,
success: function (data, status, xhr) {
// update command is executed.
commit(true);
dataAdapter.dataBind();
if (data == 1) var n1 = noty({ text: ‘Users <b>successfully </b> has been deleted!!’, timeout: 1500 });
else var n2 = noty({ text: ‘Deletion is has not done!’ });}
}, 500);
});},
localdata: data.d
};
//———————————————————-CONTEXT MENU ADAUGARE—————————————————————$(“#Nume_ID”).addClass(‘jqx-input’);
$(“#Responsabil_ID”).addClass(‘jqx-input’);
$(“#Clasa_ID”).addClass(‘jqx-input’);$(“#Nume_ID”).width(150);
$(“#Nume_ID”).height(23);$(“#Responsabil_ID”).width(150);
$(“#Responsabil_ID”).height(23);$(“#Clasa_ID”).width(150);
$(“#Clasa_ID”).height(23);var dataAdapter = new $.jqx.dataAdapter(source, {autoBind: true });
var editrow = -1;//—————————Creare Context Menu
var contextMenu = $(“#Menu”).jqxMenu({
width: 200,
height: 58,
autoOpenPopup: false,
mode: ‘popup’
});$(“#jqxgrid”).on(‘contextmenu’, function () {
return false;
});//————————————-Triger Context Menu Click
$(“#addbutton”).click (function (event) {
var args = event.args;
//var rowindex = $(“#jqxgrid”).jqxGrid(‘getselectedrowindex’);// editrow = rowindex;
var offset = $(“#jqxgrid”).offset();
$(“#popupWindow2”).jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60} });
// get the clicked row’s data and initialize the input fields.
//var dataRecord = $(“#jqxgrid”).jqxButton();
//
// $(“#Nume_ID”).val(dataRecord.Nume);// $(“#Responsabil_ID”).val(dataRecord.Responsabil);
// $(“#Clasa_ID”).val(dataRecord.Clasa);
//$(“#price”).jqxNumberInput({ decimal: dataRecord.price });
// show the popup window.
$(“#popupWindow2”).jqxWindow(‘show’);
$(“[id$=hdnAddedUsers]”).val(”);
$(“[id$=hdnRemUsers]”).val(”);// var solicitareID = dataRecord.ID;
//GetAssignedUsers(solicitareID);
//GetNotAssignedUsers(0);
GetNotAssignedUsers_AddContext(0);});
//——————————–START PopUp Window and Button’s
$(“#popupWindow2”).jqxWindow({
width: 500,
height: 400,
resizable: true,
isModal: true,
autoOpen: false,
cancelButton: $(“#Cancel2”),
modalOpacity: 0.01
});
// $(“#Cancel”).jqxButton({ theme: theme });
// $(“#Save”).jqxButton({ theme: theme });
//—————————update the edited row when the user clicks the ‘Save’ button
$(“#Save2”).click(function () {
//if (editrow >= 0)
//{var row = { Clasa: $(“#Clasa_ID”).val(), Nume: $(“#Nume_ID”).val(), Responsabil: $(“#Responsabil_ID”).val()};
//price: parseFloat($(“#price”).jqxNumberInput(‘decimal’))
AddButton(row);
var postData =
{
Clasa: $(“#Clasa_ID”).val(),
Nume: $(“#Nume_ID”).val(),
Responsabil: $(“#Responsabil_ID”).val()}
dataAdapter.bindBindingUpdate();
dataAdapter.dataBind();
//$(“#jqxGrid”).jqxGrid(“updatebounddata”);var rowid = $(“#jqxgrid”).jqxGrid(‘getrowid’, editrow);
$(‘#jqxgrid’).jqxGrid(‘updaterow’, rowid, row);
$(“#popupWindow2”).jqxWindow(‘hide’);
$(‘#jqxgrid’).jqxGrid(‘updatebounddata’, ‘cells’);//——————–
var deletedUsers = $(“[id$=hdnRemUsers]”).val().split(“;”);
if(deletedUsers != null && deletedUsers != ‘undefined’ && deletedUsers.length > 0){
for(var iIndex = 0; iIndex < deletedUsers.length;iIndex++){
if($.isNumeric(deletedUsers[iIndex]))
GetNotAssignedUsers(deletedUsers[iIndex], row.ID);
}
}var addedUsers = $(“[id$=hdnAddedUsers]”).val().split(“;”);
if(addedUsers != null && addedUsers != ‘undefined’ && addedUsers.length > 0){
for(var iIndex = 0; iIndex < addedUsers.length;iIndex++){
if($.isNumeric(addedUsers[iIndex])){
//SaveFunctionButton(addedUsers[iIndex], tipsolid);}
}
}});
//———————————————END CONTEXT MENU ADD———————————————–
//———————————————initializare contextMenu———————————————
$(“#ID”).addClass(‘jqx-input’);
$(“#Nume”).addClass(‘jqx-input’);
$(“#Responsabil”).addClass(‘jqx-input’);
$(“#Clasa”).addClass(‘jqx-input’);$(“#ID”).width(150);
$(“#ID”).height(23);$(“#Nume”).width(150);
$(“#Nume”).height(23);$(“#Responsabil”).width(150);
$(“#Responsabil”).height(23);$(“#Clasa”).width(150);
$(“#Clasa”).height(23);
// if (theme.length > 0) {
// $(“#firstName”).addClass(‘jqx-input-‘ + theme);
// $(“#lastName”).addClass(‘jqx-input-‘ + theme);
// $(“#product”).addClass(‘jqx-input-‘ + theme);
// }
//$(“#ID”).jqxNumberInput({ width: 150, height: 23, inputMode: ‘simple’, spinButtons: true });
//$(“#price”).jqxNumberInput({ symbol: ‘$’, width: 150, height: 23, spinButtons: true });var editrow = -1;
//—————————Creare Context Menu
var contextMenu = $(“#Menu”).jqxMenu({
width: 200,
height: 58,
autoOpenPopup: false,
mode: ‘popup’
});
$(“#jqxgrid”).on(‘contextmenu’, function () {
return false;
});
//————————————-Triger Context Menu Click
$(“#Menu”).on(‘itemclick’, function (event) {
var args = event.args;var rowindex = $(“#jqxgrid”).jqxGrid(‘getselectedrowindex’);
if ($.trim($(args).text()) == “Editati Randul Selectat”)
{
editrow = rowindex;
var offset = $(“#jqxgrid”).offset();
$(“#popupWindow”).jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60} });
// get the clicked row’s data and initialize the input fields.
var dataRecord = $(“#jqxgrid”).jqxGrid(‘getrowdata’, editrow);
$(“#ID”).val(dataRecord.ID);$(“#Nume”).val(dataRecord.Nume);
$(“#Responsabil”).val(dataRecord.Responsabil);
$(“#Clasa”).val(dataRecord.Clasa);
//$(“#price”).jqxNumberInput({ decimal: dataRecord.price });
// show the popup window.
$(“#popupWindow”).jqxWindow(‘show’);
$(“[id$=hdnAddedUsers]”).val(”);
$(“[id$=hdnRemUsers]”).val(”);var solicitareID = dataRecord.ID;
GetAssignedUsers(solicitareID);
GetNotAssignedUsers(solicitareID);}
else
{
var rowid = $(“#jqxgrid”).jqxGrid(‘getrowid’, rowindex);
$(“#jqxgrid”).jqxGrid(‘deleterow’, rowid);
}
});$(“#jqxgrid”).on(‘rowclick’, function (event) {
if (event.args.rightclick) {
$(“#jqxgrid”).jqxGrid(‘selectrow’, event.args.rowindex);
var scrollTop = $(window).scrollTop();
var scrollLeft = $(window).scrollLeft();
contextMenu.jqxMenu(‘open’, parseInt(event.args.originalEvent.clientX) + 5 + scrollLeft, parseInt(event.args.originalEvent.clientY) + 5 + scrollTop);
return false;
}
});//——————————–START PopUp Window and Buttons
$(“#popupWindow”).jqxWindow({
width: 500,
height: 400,
resizable: true,
isModal: true,
autoOpen: false,
cancelButton: $(“#Cancel”),
modalOpacity: 0.01
});
// $(“#Cancel”).jqxButton({ theme: theme });
// $(“#Save”).jqxButton({ theme: theme });
//—————————update the edited row when the user clicks the ‘Save’ button
$(“#Save”).click(function () {
if (editrow >= 0)
{var row = { ID: $(“#ID”).val(), Clasa: $(“#Clasa”).val(), Nume: $(“#Nume”).val(), Responsabil: $(“#Responsabil”).val()};
//price: parseFloat($(“#price”).jqxNumberInput(‘decimal’))//var listbox = { };
var rowid = $(“#jqxgrid”).jqxGrid(‘getrowid’, editrow);
$(‘#jqxgrid’).jqxGrid(‘updaterow’, rowid, row);
$(“#popupWindow”).jqxWindow(‘hide’);var deletedUsers = $(“[id$=hdnRemUsers]”).val().split(“;”);
if(deletedUsers != null && deletedUsers != ‘undefined’ && deletedUsers.length > 0){
for(var iIndex = 0; iIndex < deletedUsers.length;iIndex++){
if($.isNumeric(deletedUsers[iIndex]))
DeleteFromAssignedUser(deletedUsers[iIndex], row.ID);
}
}var addedUsers = $(“[id$=hdnAddedUsers]”).val().split(“;”);
if(addedUsers != null && addedUsers != ‘undefined’ && addedUsers.length > 0){
for(var iIndex = 0; iIndex < addedUsers.length;iIndex++){
if($.isNumeric(addedUsers[iIndex]))
SaveFunction(addedUsers[iIndex], row.ID);
}
}
}});
//————————————–finishContextMenu———————–
//——————————————————————————————-filtru
var addfilterUser = function () {
var filtergroup = new $.jqx.filter();
var filter_or_operator = 1;
var filtervalue = $(‘#UserFullName’).text().trim();
var filtercondition = ‘contains’;
var filter1 = filtergroup.createfilter(‘stringfilter’, filtervalue, filtercondition);filtergroup.addfilter(filter_or_operator, filter1);
// add the filters.
$(“#jqxgrid”).jqxGrid(‘addfilter’, ‘Catre’, filtergroup);
//return filtergroup;
$(“#jqxgrid”).jqxGrid(‘applyfilters’);
}var addfilterInit = function () {
var filtergroup = new $.jqx.filter();
var filter_or_operator = 1;
var filtertype = ‘stringfilter’;
var filtervalue = ‘Initiat’;
var filtercondition = ‘contains’;
var filter1 = filtergroup.createfilter(‘numericfilter’, filtertype, filtervalue, filtercondition);filtergroup.addfilter(filter_or_operator, filter1);
// add the filters.
$(“#jqxgrid”).jqxGrid(‘addfilter’, ‘Initiat’, filtergroup);
//return filtergroup;
$(“#jqxgrid”).jqxGrid(‘applyfilters’);
}//—————————————————————————————-
var dataAdapter = new $.jqx.dataAdapter(source);
$(“#jqxgrid”).jqxGrid({
source: dataAdapter,
pageable: true,
autoheight: true,
columnsresize: true,
theme: ‘energyblue’,
width: ‘100%’,
//height: 280,
width: 980,
enabletooltips: true,
selectionmode: ‘multiplerowsextended’,
//selectionmode: ‘checkbox’,
sorttogglestates: 1,
showfilterrow: true,
filterable: true,
sortable: true,
autorowheight: true,
pagesize: 10,
pagesizeoptions: [’10’, ’20’, ’50’, ‘100’, ‘200’, ‘226’],
altrows: true,
autoheight: true,
enablemousewheel: true,
editmode: ‘click’,
showeverpresentrow: true,
everpresentrowposition: “top”,
editable: true,
//virtualmode: true,
rendergridrows: function (obj) {
return obj.data;
},columns: [
{ dataField: ‘ID’, text: ‘ID’, width: 90, filtertype: ‘number’, autoresizable: true },
{ dataField: ‘Nume’, columntype: ‘textbox’, text: ‘Nume’, width: 280, filtertype: ‘input’ },
{ dataField: ‘Responsabil’, columntype: ‘textbox’, text: ‘Responsabil’, width: 260, filtertype: ‘bool’, columntype: ‘checkbox’},
{ dataField: ‘Clasa’, columntype: ‘textbox’, text: ‘Clasa’, width: 350, filtertype: ‘input’},],
ready: function ()
{
addfilterUser();
addfilterInit();
// apply the filters.
$(“#jqxgrid”).jqxGrid(‘applyfilters’);
}});
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
console.log(xmlHttpRequest.responseText);
console.log(textStatus);
console.log(errorThrown);
},// var editmodes = [‘Double-Click’];
// $(“#editmodes”).jqxDropDownList({
// autoDropDownHeight: true,
// dropDownWidth: 150,
// width: 150,
// height: 25,
// selectedIndex: 0,
// source: editModes
// });
// $(“#ID”).jqxCheckBox({ checked: true });
// $(“#Nume”).jqxCheckBox({ checked: true });
// $(“#Clasa”).jqxCheckBox({ checked: true });
// $(“#Responsabil”).jqxCheckBox({ checked: true });
// //$(“#quantity”).jqxCheckBox({ checked: true });
//
// // change the Edit mode.
// $(“#editmodes”).on(‘select’, function (event) {
// var index = event.args.index;
// var editMode = index == 0 ? ‘click’ : index == 1 ? ‘dblclick’ : ‘selectedcell’;
// $(“#jqxgrid”).jqxGrid({ editmode: editMode });
// });// // change the Columns Editable state.
// $(“#ID, #Nume, #Responsabil, #Clasa”).on(‘change’, function (event) {
// var datafield = event.target.id;
// $(“#jqxgrid”).jqxGrid(‘setcolumnproperty’, datafield, ‘editable’, event.args.checked);
// });});
});function GetParams(data) {
data.pagenum = data.pagenum || 0;
data.pagesize = data.pagesize || 10;
data.sortdatafield = data.sortdatafield || ‘ID’;
data.sortorder = data.sortorder || ‘asc’;
data.filterscount = data.filterscount || 0;
formatedData = buildQueryString(data);
return formatedData;
}//—————————————————————-until here—————————————–
//————————————————————————————-Function for BUTTON ADD ——–
function GetNotAssignedUsers_AddContext(tipSolicitareID){
var data = jQuery.parseJSON(‘{“ID”:”‘ + tipSolicitareID + ‘”}’);
$(“[id$=ListBox4]”).empty();
$.ajax({
type:’post’,
url: ‘/api/TipSolicitari.asmx/Users_AddContext’,
contentType: “application/json; charset=utf-8”,
dataType: “json”,
data:JSON.stringify(data),
success: function (data) {
var users = $.parseJSON(data.d);
$.each(users, function(index, value) {
$(“[id$=ListBox3]”).append($(‘<option>’).text(value.UserName).val(value.ID));});
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
console.log(xmlHttpRequest.responseText);
console.log(textStatus);
console.log(errorThrown);
},
});
}function SaveFunctionButton(userid, tipsolid)
{
var data = jQuery.parseJSON(‘{“tipsolid”:”‘ + tipsolid + ‘”, “userid”:”‘ + userid + ‘”}’);
$.ajax({
type:’post’,
url: ‘/api/TipSolicitari.asmx/SaveFunctionButton’,
contentType: “application/json; charset=utf-8”,
dataType: “json”,
data:JSON.stringify(data),
success: function (data) {
alert(‘debug1SAVE’);
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
console.log(xmlHttpRequest.responseText);
console.log(textStatus);
console.log(errorThrown);
},
});
}//————————————————————————————END Function BUTTON ADD———
function GetAssignedUsers(tipSolicitareID){$(“[id$=ListBox2]”).empty();
var data = jQuery.parseJSON(‘{“ID”:”‘+ tipSolicitareID + ‘”}’);
$.ajax({
type:’post’,
url: ‘/api/TipSolicitari.asmx/Useri_Asignati’,
contentType: “application/json; charset=utf-8”,
dataType: “json”,
data:JSON.stringify(data),
success: function (data) {
//listbox2
//$(“[id$=ListBox2]”)
var users = $.parseJSON(data.d);
$.each(users, function(index, value) {
$(“[id$=ListBox2]”).append($(‘<option>’).text(value.UserName).val(value.ID));
//$(“[id$=hdnAddedUsers]”).val($(“[id$=hdnAddedUsers]”).val() + “;” + value.ID + “;”);
});},
error: function (xmlHttpRequest, textStatus, errorThrown) {
console.log(xmlHttpRequest.responseText);
console.log(textStatus);
console.log(errorThrown);
},
});
}function GetNotAssignedUsers(tipSolicitareID){
var data = jQuery.parseJSON(‘{“ID”:”‘ + tipSolicitareID + ‘”}’);
$(“[id$=ListBox1]”).empty();
$.ajax({
type:’post’,
url: ‘/api/TipSolicitari.asmx/Useri_Neasignati’,
contentType: “application/json; charset=utf-8”,
dataType: “json”,
data:JSON.stringify(data),
success: function (data) {
var users = $.parseJSON(data.d);
$.each(users, function(index, value) {
$(“[id$=ListBox1]”).append($(‘<option>’).text(value.UserName).val(value.ID));});
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
console.log(xmlHttpRequest.responseText);
console.log(textStatus);
console.log(errorThrown);
},
});
}//——————————————————————————————–
function SaveFunction(userid, tipsolid)
{
var data = jQuery.parseJSON(‘{“tipsolid”:”‘ + tipsolid + ‘”, “userid”:”‘ + userid + ‘”}’);
$.ajax({
type:’post’,
url: ‘/api/TipSolicitari.asmx/UserToTipSolicitare_Insert’,
contentType: “application/json; charset=utf-8”,
dataType: “json”,
data:JSON.stringify(data),
success: function (data) {
//alert(‘debug1’);
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
console.log(xmlHttpRequest.responseText);
console.log(textStatus);
console.log(errorThrown);
},
});
setTimeout(function() {$(“#jqxgrid”).jqxGrid(‘userid’,{datatype:’json’}); },50);
}function DeleteFromAssignedUser(userid, tipsolid){
var data = jQuery.parseJSON(‘{“tipsolid”:”‘ + tipsolid + ‘”, “userid”:”‘ + userid + ‘”}’ );
$.ajax({
type:’post’,
url: ‘/api/TipSolicitari.asmx/UserToTipSolicitare_DELETE’,
contentType: “application/json; charset=utf-8”,
dataType: “json”,
data:JSON.stringify(data),
success: function (data) {
// alert(‘debug2’);
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
console.log(xmlHttpRequest.responseText);
console.log(textStatus);
console.log(errorThrown);
},
});
}function AddButton(row){
var Nume_ID=$(‘#Nume_ID’).val();
var Responsabil_ID=$(‘#Responsabil_ID’).val();
var Clasa_ID=$(‘#Clasa_ID’).val();
var addedUsers = $(“[id$=hdnAddedUsers]”).val().split(“;”);
if(addedUsers != null && addedUsers != ‘undefined’ && addedUsers.length > 0){
for(var iIndex = 0; iIndex < addedUsers.length;iIndex++){
if($.isNumeric(addedUsers[iIndex])){//SaveFunction(addedUsers[iIndex], row.ID);
}
}
}var data = “insert=true&Nume_ID=” + Nume_ID + “&Responsabil_ID=” + Responsabil_ID + “&Clasa_ID=” + Clasa_ID+ “&UserIDs=” + addedUsers;
$.ajaxSetup({ async: false });
$.ajax({
dataType: ‘json’,
url: ‘/api/TipSolicitari.asmx/TipSolicitari_Insert_AddButton’,
//url: ‘/api/TipSolicitari.asmx/SaveFunctionButton’,
cache: false,
data: data,
type: “get”,success: function (data, status, xhr) {
// update command is executed.
commit(true);
alert(‘work’);
console.log(data);
dataAdapter.dataBind();
}
//
// ,
// error: function () {
// commit(false);
// alert(‘Does not work’);
// }
});//setTimeout(function() {$(“#jqxgrid”).jqxGrid(‘setGridParam’,{datatype:’json’}); },5);
$.ajaxSetup({ async: true });
return false;
}// void Page_Load(Object sender, EventArgs e)
// {
//
// if(!IsPostBack)
// {// // Declare the query string.
// String queryString =
// “Select [ID], [Nume], [Responsabil], [Clasa] From [TipSolicitare]”;// // Run the query and bind the resulting DataSet
// // to the GridView control.
// DataSet ds = GetData(queryString);
// if (ds.Tables.Count > 0)
// {
// AuthorsGridView.DataSource = ds;
// AuthorsGridView.DataBind();
// }
// else
// {
// Message.Text = “Unable to connect to the database.”;
// }// }
// }
// DataSet GetData(String queryString)
// {// // Retrieve the connection string stored in the Web.config file.
// String connectionString = ConfigurationManager.ConnectionStrings[“connectionString”].ConnectionString;// DataSet ds = new DataSet();
// try
// {
// // Connect to the database and run the query.
// SqlConnection connection = new SqlConnection(connectionString);
// SqlDataAdapter adapter = new SqlDataAdapter(queryString, connection);// // Fill the DataSet.
// adapter.Fill(ds);// }
// catch(Exception ex)
// {// // The connection failed. Display an error message.
// Message.Text = “Unable to connect to the database.”;// }
// return ds;
// }
//var data = jQuery.parseJSON(‘{“Nume”:”‘ + Nume + ‘”, “Responsabil”:”‘ + Responsabil + ‘”, “Clasa”:”‘ + Clasa + ‘”}’);
// $.ajax({
// //type:’post’,
// url: ‘/api/TipSolicitari.asmx/TipSolicitari_Insert’,
// contentType: “application/json; charset=utf-8”,
// dataType: “json”,
// data:JSON.stringify(data),
// success: function (data) {
// alert(‘debug2’);
// },
// error: function (xmlHttpRequest, textStatus, errorThrown) {
// console.log(xmlHttpRequest.responseText);
// console.log(textStatus);
// console.log(errorThrown);
// },
// });//}
//————————————————————-//———————————————————————————–
</script>
<input type=”hidden” id=”gridData” name=”gridData” />
<input type=”hidden” id=”hidGridFormatedData” name=”hidGridFormatedData” />
<input type=”hidden” id=”hdnLoginID” name=”hdnLoginID” runat=”server” />
<input type=”hidden” id=”hdnLoginName” name=”hdnLoginName” runat=”server” />
<input type=”hidden” id=”hdnIsPostBack” name=”hdnIsPostBack” runat=”server” />
<input type=”hidden” id=”hdnRemUsers” name=”hdnRemUsers” runat=”server” />
<input type=”hidden” id=”hdnAddedUsers” name=”hdnAddedUsers” runat=”server” />
<%– <input type=”hidden” id=”hdnAddedUsers2″ name=”hdnAddedUsers2″ runat=”server” />–%><div id=”form1″ runat=”server” class=”content”>
<div style=”float: left; vertical-align: top; margin-left: 20px; margin-right: 10px;
margin-top: 5px; font-weight: bold;”>
<span id=”ctl00_SiteMapPath1″><span>Home</span><span> > </span><span>Tip Solicitari</span></span>
</div><div id=”templateListaFirme” runat=”server” style=”display: inline-block; margin-left: 20px; min-height: 0px;”>
</div><div style=”margin: 0px;”>
<div style=”width: 1200px; margin: 0px auto; display: block; height: 1px;”>
<div style=”float: left;”>
</div>
</div><div style=’margin-left: 20px; margin-bottom: 20px; font-size: 14px; font-family: Trebuchet MS;
color: Red’>
<u><b>Click dreapta pe linie pentru editare/stergere</b></u></div>
<div style=’display: inline;’>
<div style=’margin-left: 10px; margin-bottom: 20px; display: inline;’>
<input type=”button” value=”Adaugare” id=”addbutton” style=”margin-bottom: 7px;”/></div>
</div>
<div id=’jqxWidget’ style=”font-size: 12px; font-family: Trebuchet MS;”>
<div id=”jqxgrid”>
</div>
</div><div id=”popupWindow” >
<div>Editare</div>
<div style=”overflow: hidden;”>
<table>
<tr>
<td align=”right”>ID:</td>
<td align=”left”><input id=”ID” /></td>
</tr>
<tr>
<td align=”right”>Clasa:</td>
<td align=”left”><input id=”Clasa” /></td>
</tr>
<tr>
<td align=”right”>Nume:</td>
<td align=”left”><input id=”Nume” /></td>
</tr>
<tr>
<td align=”right”>Responsabil:</td>
<td align=”left”><input id=”Responsabil” /></td>
</tr><%–<tr>
<td align=”right”>Price:</td>
<td align=”left”><div id=”price”></div></td>
</tr>–%><tr>
<td colspan=2>
<div style=”float:left;”>
<asp:ListBox ID=”ListBox1″ runat=”server” multiple=”multiple” name=”ListBox1″ ClientID=”Static” style=”width:160px;border:solid 1px #b5b5b5;” >
</asp:ListBox>
</div>
<div style=”float:left;”>
<input type=’button’ id=’btnRight’ value =’ >> ‘ />
<br/>
<input type=’button’ id=’btnLeft’ value =’ << ‘/>
</div>
<div style=”float:left;”>
<asp:ListBox ID=”ListBox2″ runat=”server” multiple=”multiple” name=”ListBox2″ ClientIDMode=”Static” style=”width:160px;border:solid 1px #b5b5b5;”>
</asp:ListBox>
</div>
</td>
</tr><tr>
<td align=”right”></td>
<td style=”padding-top: 10px;” align=”right”><input style=”margin-right: 5px;” type=”button” id=”Save” value=”Save” /><input id=”Cancel” type=”button” value=”Cancel” /></td>
</tr>
</table>
</div>
</div>
</div><div id=’Menu’>
- Editati Randul Selectat
- Stergeti Randul Selectat
</div>
<div id=”popupWindow2″ >
<div>Editare</div>
<div style=”overflow: hidden;”>
<table>
<tr>
<td align=”right”>Nume:</td>
<td align=”left”><input id=”Nume_ID” /></td>
</tr>
<tr>
<td align=”right”>Clasa:</td>
<td align=”left”><input id=”Clasa_ID” /></td>
</tr>
<tr>
<td align=”right”>Responsabil:</td>
<td align=”left”><!–input id=”Responsabil_ID” /–><select id=”Responsabil_ID”><option value=”true”>True</option><option value=”false”>False</option></select></td>
</tr><tr>
<td colspan=2>
<div style=”float:left;”>
<asp:ListBox ID=”ListBox3″ runat=”server” multiple=”multiple” name=”ListBox3″ ClientID=”Static” style=”width:160px;border:solid 1px #b5b5b5;” >
</asp:ListBox>
</div>
<div style=”float:left;”>
<input type=’button’ id=’btnRight1′ value =’ >> ‘/>
<br/>
<input type=’button’ id=’btnLeft2′ value =’ << ‘/>
</div>
<div style=”float:left;”>
<asp:ListBox ID=”ListBox4″ runat=”server” multiple=”multiple” name=”ListBox4″ ClientIDMode=”Static” style=”width:160px;border:solid 1px #b5b5b5;”>
</asp:ListBox>
</div>
</td>
</tr><tr>
<td align=”right”></td>
<td style=”padding-top: 10px;” align=”right”><input style=”margin-right: 5px;” type=”button” id=”Save2″ value=”Salvare” /><input id=”Cancel2″ type=”button” value=”Anulare” /></td>
</tr>
</table>
</div>
</div>
</div></div>
</asp:Content>
Hello edd,
I did one fast review of your code, but this is one complicated source code and we cannot spend as much time on each one project.
Please, provide us a small example that demonstrates a concrete issue.
That I noticed:
– the places where you use the callbacks of the DataAdapter source – “addRow” need to be with lowercase letters “addrow” (the same thing goes for “updateRow” and “deleteRow”).
– when you use “rendergridrows” need to setvirtualmode: true
. Both are interconnected.
I would like to suggest you this demo (in the ASP.NET section) and this article.
Also, I would like to ask you for any error messages?
Thank you for your understanding.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.