jQWidgets Forums
Forum Replies Created
-
Author
-
August 19, 2012 at 12:56 pm in reply to: How to implement edit in modal popup in grid, modal popup opens on click of icon How to implement edit in modal popup in grid, modal popup opens on click of icon #6872
Hi,
Following is the solution that I found for my problem. Using this button click event I was able to edit in the popup.
var buttonClickEdit = function (event, row) { // open the popup window when the user clicks a button. id = event.target.id; var value = $("#jqxgrid").jqxGrid('getcellvalue', id, 'UserID'); var offset = $("#jqxgrid").offset(); $("#popupWindow").jqxWindow({ position: { x: parseInt(offset.right) + 60, y: parseInt(offset.top) + 20} }); $("#popupWindow").jqxWindow('setContent', 'Loading...'); alert(urlRedirectEdit + '/' + value); var jqxhr = $.get(urlRedirectEdit + '/' + value, function (data) { //alert(data); $("#popupWindow").jqxWindow('setContent', data); }) .success(function (data) { // alert("Success"); }) .error(function () {// alert("Failure"); }) .complete(function () {// alert("Complete"); }); $("#popupWindow").jqxWindow('show');}
August 19, 2012 at 12:53 pm in reply to: Rendering View in a Modal Popup Rendering View in a Modal Popup #6871Hi,
I had already gone through the example posted by you. Though I could open the modal popup from the grid,
I was unable to render a view in it. However I have solved the problem now. Following is the code snippet.var urlRedirectEdit = '@Url.Action("Edit","User")'; var urlRedirectDelete = '@Url.Action("Delete","User")'; var urlGetUsers = '@Url.Action("GetUsers","User")';var buttonClickEdit = function (event, row) { // open the popup window when the user clicks a button. id = event.target.id; var value = $("#jqxgrid").jqxGrid('getcellvalue', id, 'UserID'); var offset = $("#jqxgrid").offset(); $("#popupWindow").jqxWindow({ position: { x: parseInt(offset.right) + 60, y: parseInt(offset.top) + 20} }); $("#popupWindow").jqxWindow('setContent', 'Loading...'); alert(urlRedirectEdit + '/' + value); var jqxhr = $.get(urlRedirectEdit + '/' + value, function (data) { //alert(data); $("#popupWindow").jqxWindow('setContent', data); }) .success(function (data) { // alert("Success"); }) .error(function () {// alert("Failure"); }) .complete(function () {// alert("Complete"); }); $("#popupWindow").jqxWindow('show');}var buttonClickDelete = function (event, row) { // open the popup window when the user clicks a button. id = event.target.id; var value = $("#jqxgrid").jqxGrid('getcellvalue', id, 'UserID'); var offset = $("#jqxgrid").offset(); $("#popupWindow").jqxWindow({ position: { x: parseInt(offset.right) + 60, y: parseInt(offset.top) + 20} }); $("#popupWindow").jqxWindow('setContent', 'Loading...'); var jqxhr = $.get(urlRedirectDelete + '/' + value, function (data) { //alert(data); $("#popupWindow").jqxWindow('setContent', data); }) .success(function (data) { // alert("Success"); }) .error(function () {// alert("Failure"); }) .complete(function () {// alert("Complete"); }); $("#popupWindow").jqxWindow('show');}var GetQueryStringParams = function (sParam) { var sPageURL = window.location.search.substring(1); // alert(sPageURL); var sURLVariables = sPageURL.split('&'); for (var i = 0; i < sURLVariables.length; i++) { var sParameterName = sURLVariables[i].split('='); if (sParameterName[0] == sParam) { return sParameterName[1]; } }}$(document).ready(function () { // alert(GetQueryStringParams('userid')); var source = { datatype: "json", datafields: [{ name: 'UserID' }, { name: 'UserName' }, { name: 'ParentUserID' }, { name: 'FirstName' }, { name: 'LastName' }, { name: 'City' }, { name: 'Phone' }, { name: 'Email' }, { name: 'UserIsActive', type: 'bool' }, { name: 'UserCreatedOn', type: 'date' }, { name: 'UserLastModifiedOn', type: 'date'}], url: urlGetUsers, data: { userid: GetQueryStringParams('userid') }, contentType: "application/json; charset=utf-8", id: 'UserID' }; var dataAdapter = new $.jqx.dataAdapter(source, { downloadComplete: function (data, status, xhr) { }, loadComplete: function (data) { }, loadError: function (xhr, status, error) { } }); var editrow = -1; var deleterow = -1; $("#jqxgrid").jqxGrid({ width: 1100, source: dataAdapter, theme: 'darkblue', filterable: true, sortable: true, pageable: true, selectionmode: 'singlerow', groupable: true, enabletooltips: true, autoshowfiltericon: true, columns: [{ text: 'UserID', datafield: 'UserID', width: 50 }, { text: 'UserName', datafield: 'UserName', width: 150 }, { text: 'ParentUserID', datafield: 'ParentUserID', width: 50 }, { text: 'FirstName', datafield: 'FirstName', width: 150 }, { text: 'LastName', datafield: 'LastName', width: 150 }, { text: 'City', datafield: 'City', width: 120 }, { text: 'Phone', datafield: 'Phone', width: 120 }, { text: 'Email', datafield: 'Email', width: 120 }, { text: 'UserIsActive', columntype: 'checkbox', datafield: 'UserIsActive', width: 100 }, { text: 'UserCreatedOn', datafield: 'UserCreatedOn', columntype: 'datetimeinput', width: 100, cellsformat: 'D' }, { text: 'UserLastModifiedOn', datafield: 'UserLastModifiedOn', columntype: 'datetimeinput', width: 100, cellsformat: 'D' }, { text: 'Edit', datafield: 'Image', width: 60, cellsrenderer: function (row) { return '<a href="#" onClick="buttonClickEdit(event)" width="20" height="20"><img id="' + row + '" style="margin-left: 5px;" height="20" width="20" src="../Content/images/Edit.png"/></a>'; } }, { text: 'Delete', datafield: 'Image', width: 60, cellsrenderer: function (row) { return '<a href="#" onClick="buttonClickDelete(event)" width="20" height="20"><img id="' + row + '" style="margin-left: 5px;" height="20" width="20" src="../Content/images/Delete.png"/></a>'; } } ] }); $('#clearfilteringbutton').jqxButton({ height: 25, theme: 'darkblue' }); $('#filterbackground').jqxCheckBox({ checked: true, height: 25, theme: 'darkblue' }); $('#filtericons').jqxCheckBox({ checked: false, height: 25, theme: 'darkblue' }); // clear the filtering. $('#clearfilteringbutton').click(function () { $("#jqxgrid").jqxGrid('clearfilters'); }); // show/hide filter background $('#filterbackground').bind('change', function (event) { $("#jqxgrid").jqxGrid({ showfiltercolumnbackground: event.args.checked }); }); // show/hide filter icons $('#filtericons').bind('change', function (event) { $("#jqxgrid").jqxGrid({ autoshowfiltericon: !event.args.checked }); }); // initialize the popup window and buttons. $("#popupWindow").jqxWindow({ width: 500, height: 1300, resizable: true, theme: 'darkblue', isModal: true, autoOpen: false, modalOpacity: 0.01 }); $("#popupWindow1").jqxWindow({ width: 250, height: 500, resizable: true, theme: 'darkblue', isModal: true, autoOpen: false, modalOpacity: 0.01 });});
In the buttonclickEdit and buttonClickDelete events I have rendered the view using
var jqxhr = $.get(urlRedirectEdit + ‘/’ + value, function (data) {
//alert(data);
$(“#popupWindow”).jqxWindow(‘setContent’, data);
})August 12, 2012 at 7:42 pm in reply to: How to implement edit in modal popup in grid, modal popup opens on click of icon How to implement edit in modal popup in grid, modal popup opens on click of icon #6736I am unable to enter the html part of the code here- the edit and delete cellsrenderer function return anchor tags within which image tag is present
August 12, 2012 at 7:40 pm in reply to: How to implement edit in modal popup in grid, modal popup opens on click of icon How to implement edit in modal popup in grid, modal popup opens on click of icon #6735$(document).ready(function () {
var source = {
datatype: “json”,
datafields: [{ name: ‘UserName’ },
{ name: ‘FirstName’ }, { name: ‘Phone’ }, { name: ‘City’ },
{ name: ‘Discontinued’, type: ‘bool’}],
url: ‘User/GetUsers’,
id: ‘UserID’,};
var dataAdapter = new $.jqx.dataAdapter(source, {
downloadComplete: function (data, status, xhr) { },
loadComplete: function (data) { },
loadError: function (xhr, status, error) { }
});
var editrow = -1;
var deleterow = -1;
$(“#jqxgrid”).jqxGrid({
width: 860,
source: dataAdapter,
editable: true,
theme: ‘darkblue’,
filterable: true,
sortable: true,
pageable: true,
selectionmode: ‘singlerow’,
editmode: ‘click’,
groupable: true,
enabletooltips: true,
autoshowfiltericon: true,
columns: [{ columntype: ‘checkbox’, datafield: ‘discontinued’, width: 100 },{ text: ‘UserName’, datafield: ‘UserName’, width: 150 },
{ text: ‘FirstName’, datafield: ‘FirstName’, width: 180 },
{ text: ‘Phone’, datafield: ‘Phone’, width: 200 },
{ text: ‘City’, datafield: ‘City’, width: 120 },
{ text: ‘Edit’, datafield: ‘Edit’, width: 60, cellsrenderer: function () {
return ‘‘;
}
},{ text: ‘Delete’, datafield: ‘Image’, width: 60, cellsrenderer: function () {
return ‘‘;
}
}]
});
$(“#discontinued”).jqxCheckBox({ theme: ‘darkblue’, checked: true });
$(‘#clearfilteringbutton’).jqxButton({ height: 25, theme: ‘darkblue’ });
$(‘#filterbackground’).jqxCheckBox({ checked: true, height: 25, theme: ‘darkblue’ });
$(‘#filtericons’).jqxCheckBox({ checked: false, height: 25, theme: ‘darkblue’ });
// clear the filtering.
$(‘#clearfilteringbutton’).click(function () {
$(“#jqxgrid”).jqxGrid(‘clearfilters’);
});
// show/hide filter background
$(‘#filterbackground’).bind(‘change’, function (event) {
$(“#jqxgrid”).jqxGrid({ showfiltercolumnbackground: event.args.checked });
});
// show/hide filter icons
$(‘#filtericons’).bind(‘change’, function (event) {
$(“#jqxgrid”).jqxGrid({ autoshowfiltericon: !event.args.checked });
});// initialize the popup window and buttons.
$(“#popupWindow”).jqxWindow({ width: 250, height: 230, resizable: true, theme: ‘darkblue’, isModal: true, autoOpen: false, saveButton: $(“#Save”), cancelButton: $(“#Cancel”), modalOpacity: 0.01 });
$(“#popupWindow1”).jqxWindow({ width: 250, height: 230, resizable: true, theme: ‘darkblue’, isModal: true, autoOpen: false, cancelButton: $(“#CancelD”), modalOpacity: 0.01 });
$(“#Cancel”).jqxButton({ theme: ‘darkblue’ });
$(“#Save”).jqxButton({ theme: ‘darkblue’ });
$(“#CancelD”).jqxButton({ theme: ‘darkblue’ });
$(“#Delete”).jqxButton({ theme: ‘darkblue’ });
// update the edited row when the user clicks the ‘Save’ button.
$(“#Save”).click(function () {
if (editrow >= 0) {
var row = { UserName: $(“#UserName”).val(), FirstName: $(“#FirstName”).val(), City: $(“#City”).val(),
Phone: parseInt($(“#Phone”).jqxNumberInput(‘decimal’))
};
$(‘#jqxgrid’).jqxGrid(‘updaterow’, editrow, row);
$(“#popupWindow”).jqxWindow(‘hide’);
}$(“#Delete”).click(function () {
if (deleterow >= 0) {
var row = { UserName: $(“#UserNameD”).val(), FirstName: $(“#FirstNameD”).val(), City: $(“#CityD”).val(),
Phone: parseInt($(“#PhoneD”).jqxNumberInput(‘decimal’))
};
$(‘#jqxgrid’).jqxGrid(‘deleterow’, deleterow, row);
$(“#popupWindow1”).jqxWindow(‘hide’);
}
});});
});var buttonClickDelete = function (event, row) {
// open the popup window when the user clicks a button.
alert(‘HereDelete’);
deleterow = row;
var offset = $(“#jqxgrid”).offset();
$(“#popupWindow1”).jqxWindow({ position: { x: parseInt(offset.right) + 60, y: parseInt(offset.top) + 60} });
// get the clicked row’s data and initialize the input fields.
var dataRecord = $(“#jqxgrid”).jqxGrid(‘getrowdata’, deleterow);
$(“#UserNameD”).val(dataRecord.UserName);
$(“#FirstNameD”).val(dataRecord.FirstName);
$(“#PhoneD”).val(dataRecord.Phone);
$(“#CityD”).val(dataRecord.City);
// show the popup window.
$(“#popupWindow1”).jqxWindow(‘show’);
}
var buttonClickEdit = function (event, row) {
// open the popup window when the user clicks a button.
alert(event);
editrow = row;
var offset = $(“#jqxgrid”).offset();
$(“#popupWindow”).jqxWindow({ position: { x: parseInt(offset.right) + 60, y: parseInt(offset.top) + 60} });
// get the clicked row’s data and initialize the input fields.
var dataRecord = $(“#jqxgrid”).jqxGrid(‘getrowdata’, editrow);
$(“#UserName”).val(dataRecord.UserName);
$(“#FirstName”).val(dataRecord.FirstName);
$(“#Phone”).val(dataRecord.Phone);
$(“#City”).val(dataRecord.City);
// show the popup window.
$(“#popupWindow”).jqxWindow(‘show’);
}EditUserName:
FirstName:
Phone:
City:
DeleteUserName:
FirstName:
Phone:
City:
Filter BackgroundShow All Filter Icons -
AuthorPosts