Monday, February 23, 2009

Basic jQGrid Implementation with WCF Service

I have made a very generic and simple working model of jQgrid with wcf service. You can download it from here.

I am working for a complete working model. Will upload it once its done.

23 comments:

Born2Code said...

Hi,

The code was really helped me. Can please send me latest copy with edit and add.

Born2Code said...

Hi:

i need to show a POC on jgrid with find, edit and add data.

Please can you send the you latest POC project.

thanx
prabhakaran

Unknown said...

Hi Prabhakaran,

Am glad the project helped you, Will upload the latest one by tonight!

Thanks Wali.

Alberto said...

Hi,

I struggled a lot to find a solution. Your sample code helped me do it in a few minutes. Thanks.

Alberto

Born2Code said...

Hi Guru:

Thank You for your kind mail.

I am waiting for your Latest Project. Hope you can help in building a new light weight framework, which can be used to build the WEB applications.

Phase I :
Framework supports the business actives using WCF.
Like addition, modification and deletion of records from grid.
Import and export the data to & by Excel sheets.
Dynamic menu
Administration module / changes the site properties.

Phase II :
Need to have client side reporting activities
Advanced : Administration module – Like having some properties of portal
Advanced : Dynamic menu – Permission Control.
But it will grow all in discussion

Hope you have understood my current situation.
Millions of thanks in advance. Hoping that you will help me in this mission.

Thanks
Prabhakaran

Unknown said...

Hi Alberto,

Am glad it worked for you!!! Actually i had struggled a lot to implement that basic thing... so i never wanted someone else to go thru that phase....

Thanks,
Wali.

Unknown said...

Hi Prabhakaran,

I guess current version will surely help you in first phase, i will share how the add and update has worked out.

Thanks Wali.

Born2Code said...

Hi Wali:

Thanks, I am waiting for your updated code.

I tried lot , but sorting and search is also not working for me.

Note: I am very new to development. Please help me.

Can you please share your contact number.

Thanks
Prabhakaran

Unknown said...

Hi Dude!

Look at my latest post... that will help you.

Thanks,
Wali.

Born2Code said...

Hi Guru:

Thanks a lot, will come back to you soon :)

Thanks
Prabhakaran

Born2Code said...

Hi Guru:

Thanks a lot, Its working fine.
But sorting, paging and search is not working.

Thanks
Prabhakaran

Born2Code said...

Hi Guru:

I am not able to get delete, sorting, paging and search to be fine.

Delete: I am getting opra:del and id value, I need to get the PK Value or entire row value as I get during the edit the row.

Hope you help me.

Waiting for your updated code.

Thanks
Prabhakaran

Unknown said...

Dude just go thru the query string you will be able to find everything.

In case of search, that will also get constructed in query string and get appended in the same. Thats probably one thing which i dint like in the control.

-Wali.

Born2Code said...

Hi Guru:

First I need to be fine with Delete.

I am getting fine other than PK value.

If I get PK value in server side the delete will be fine.

I don't know how to pass the PK value to server side.

Like I get row values during the edit.

Please give me some hint to dig it down.

Where your are building the query string.

Search: I am getting sort value and column value in server side.

But I am getting empty rows after hit to server. Please see the below code.

public IEnumerable?User? GetUserList(string sortColumn, string sortType)
{

return
from c in this.Context.Users
orderby (sortColumn + sortType)
select c;

}
I am very new to development.

hope you help me.

Thanks
Prabhakaran

Unknown said...

Dude you need to bind the PK value in Grid then only you can find it in server side, i have not checked to make a column in-visible... but it will be possible i guess.

-Wali.

Born2Code said...

Hi Guru:

Yes, I have binded the PK value in grid.

I am able to do the edit fine to that PK value:

Below is details I get during the edit.

Email
svasu@gmail.com

FullName
Santhosh

PK
6 --- This value I am not getting in delete mode

Id
3 --- I am only getting this during delete mode

oper
edit

Js:
jQuery(document).ready(function() {
var selectedRow = 0;
jQuery("#list").jqGrid({
url: 'CustomerOrders.svc/GetUsers',
datatype: "json",
colNames: ['PK', 'FullName', 'Email'],
colModel: [
{ name: 'PK', index: 'PK', width: 55, editable: true, editoptions: { readonly: true} },
{ name: 'FullName', index: 'FullName', width: 100, editable: true, editoptions: { size: 10} },
{ name: 'Email', index: 'Email', width: 150, sortable: false, editable: true, editoptions: { size: 25} }
],
rowNum: 10,
rowList: [10, 20, 30],
imgpath: '../themes/green/images',
pager: jQuery('#pager'),
sortname: 'PK',
editurl: 'CustomerOrders.svc/EditUsers',
viewrecords: true,
multiselect: false,
//multikey: "ctrlKey",
sortorder: "desc",
width: 620, // new width
height: 220,
rowheight: 10, // newrow height
//height: 'auto',
caption: "User Details",
onSelectRow: function(id) {
//We verify a valid new row selection
if (id && id !== selectedRow) {
//If a previous row was selected, but the values were not saved, we restore it to the original data.
$('#list').restoreRow(selectedRow);
//Makes inline editing possible. The id is the row id, and the true lets the component know that save records when user hits Enter, and Esc cancels the edit
$('#list').editGridRow(id, true);
//We make use of the toolbar, to let user know Enter = save, Esc = cancel
$("#list1").html("Editing - Press Enter to Save. Esc to Cancel Edit")
//Set the selectedRow
selectedRow = id;
}
},
jsonReader: {
root: "Rows",
page: "Page",
total: "TotalPages",
records: "Records",
repeatitems: false,
PK: "PK"
}
}).navGrid('#pager',
{}, //options
{reloadAfterSubmit: true, afterSubmit: commonSubmit, closeAfterEdit: true, width: "400" }, //Options for the Edit Dialog
{reloadAfterSubmit: true, afterSubmit: commonSubmit, closeAfterAdd: false, width: "400" }, //Options for the Add Dialog
{reloadAfterSubmit: true, afterSubmit: commonSubmit, closeAfterDelete: true, width: "400" }, // del options
{} // search options
);

});
function commonSubmit(data, params) {
var a = eval("(" + data.responseText + ")"); //Convert returned string into JSON
return true;
}

Thanks
Prabhakaran

Born2Code said...

Hi Guru:

Delete is working fine.

{}, //options
{reloadAfterSubmit: true, afterSubmit: commonSubmit, closeAfterEdit: true, width: "400" }, //Options for the Edit Dialog
{reloadAfterSubmit: true, afterSubmit: commonSubmit, closeAfterAdd: false, width: "400" }, //Options for the Add Dialog
{}, // del options
{} // search options
);
jQuery.jgrid.del = {
top: 100, left: 700,
url: 'CustomerOrders.svc/EditUsers',
caption: "MKP Delete",
msg: "Delete selected record(sss)?",
bSubmit: "Delete Rec",
bCancel: "Cancel",
processData: "Processingsssssss…",
beforeSubmit: function() {
var sr = jQuery("#list").getGridParam('selrow');
var rowData = jQuery("#list").getRowData(sr);

this.delData = { "id": rowData['PK'] };
retarr = { "id": rowData['PK'] };
alert(rowData['PK']);
return retarr;
},
afterSubmit: function(msg) {
alert("Done with delete");
return true;
}
};
});
function commonSubmit(data, params) {
var a = eval("(" + data.responseText + ")"); //Convert returned string into JSON
return true;
}

I need to call the above function as separate , let know how to do that.

Thanks
Prabhakaran

Anonymous said...

vab банк
vab банк
[url=http://globalist.org.ua/?p=19244]vab банк[/url]
http://globalist.org.ua/?p=19244 - vab банк

jeff said...

waaahh.. I wish I had seen your blog earlier.. thanks a lot..

Unknown said...

Never mind Jeff!, sooner the better. :)

jeff said...
This comment has been removed by the author.
jeff said...

Hi Wali Khan,
I was able to implement my first JQgrid implementation with WCF service, thanks to your post.
I have a question, how can I populate an editype:'select' using a WCF method?.. Please help me..

Thanks and regards

Unknown said...

Hi,

I am not able to download the code from the link please check