Forum

July 12th, 2025
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
how to use jqgrid with .net
08/01/2009
22:36
Avatar
khatri
New Member
Members
Forum Posts: 1
Member Since:
09/01/2009
sp_UserOfflineSmall Offline

Hi

I am populating datagrid using datatable, its a simple control of .net..

can i use jqgrid with datatable ...

09/01/2009
08:36
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

If you can provide the data described in docs you can use jqGrid.

Best Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

09/01/2009
14:25
Avatar
geek
Member
Members
Forum Posts: 10
Member Since:
29/12/2008
sp_UserOfflineSmall Offline

I know you can use it fairly easily by returning XML data.

The DataTable object has a method writeXML you can use to generate the XML very quickly.

You can use either PageMethods or create a web service with methods for exposing your data.

In my case, I have a web service that has multiple methods for providing data to my jqGrids.  Here is an example:

 [WebMethod(EnableSession = true)]
[ScriptMethod(UseHttpGet = true)]
public XmlDocument GetBranchHoldings()
{
 XmlDocument xmlDoc = new XmlDocument();

 if (HttpContext.Current.Request["id"] != null)
 {
  DataRow[] drHoldings = objScore.AccountHoldings.Select("guidBranch = '" +   HttpContext.Current.Request["id"].ToString() + "'");
  DataTable dtHoldings = objScore.AccountHoldings.Clone();

  foreach (DataRow dr in drHoldings)
  {
   dtHoldings.ImportRow(dr);
  }
  StringWriter sw = new StringWriter();
  dtHoldings.WriteXml(sw, false);
  xmlDoc.LoadXml(sw.ToString());
 }

 return xmlDoc;
}

On the client side, you specify xml as the datatype and use an xmlReader to specify the root, etc. so jqGrid knows how to load data into your grid.  Here is another example for the client side:

jQuery("#tblBuys").jqGrid({
         url: "Model.asmx/GetBranchSummary",
         datatype: "xml",
         recordtext: "Branch(s)",
         width: "850",
         shrinkToFit: true,
         xmlReader: {
            root: "DocumentElement",
            row: "Table1" ,
            page: "DocumentElement>currentpage",
            total: "DocumentElement>totalpages",
            records: "DocumentElement>totalrecords",
            repeatitems: false,
            id: "guidBranch"          
         },
         colNames: ['Branch Name', 'MarketValue', 'Pct', 'Market Value', 'Pct', 'Pct', 'Pct', 'Market Value', 'Pct'],
         colModel: [
            {name:'BranchName',index:'BranchName', width:160, sorttype:"string"},
            {name:'CurrentMV',index:'CurrentMV', width:80, align:"right",sortable:true},
            {name:'BranchActualWeight',index:'BranchActualWeight', width:80, align:"right",sortable:false},
            {name:'TargetMV',index:'TargetMV', width:80, align:"right",sortable:false},
            {name:'BranchTargetWeight',index:'BranchTargetWeight', width:80, align:"right",sortable:false},
            {name:'BranchHighLimitWeight',index:'BranchHighLimitWeight', width:80, align:"right",sortable:false},
            {name:'BranchLowLimitWeight',index:'BranchLowLimitWeight', width:80, align:"right",sortable:false},
            {name:'ProposedMV',index:'ProposedMV', width:80, align:"right",sortable:false},
            {name:'BranchProposedWeight',index:'BranchProposedWeight', width:80, align:"right",sortable:false}
         ],
         imgpath: "http://myserver/mysite/app_themes/default/resources/gridimages",
         pager: jQuery("#pgrBuys"),
         rowNum: 1,
         rowList:[5,10,15],
         viewrecords:true 
        });

 Reply if you still have questions or are confused 🙂

08/02/2009
09:51
Avatar
mcbaker
New Member
Members
Forum Posts: 1
Member Since:
04/02/2009
sp_UserOfflineSmall Offline

I would like to use jQuery Grid to display a list of current events which retrieved from a web service returning xml.  Right now I am binding this to a grid view.  I appreciate your example but have the following issues.

My xml doesn't contain the number of pages or number of records.  Looking at your example, I coded this:

    jQuery(document).ready(function(){
        jQuery("#tblOutages").jqGrid({
            url:'Reporting.asmx/OutageReportXML',
            datatype:'xml',
            width:'850',
            shrinkToFit: true,
            xmlReader:{
                root:'NewDataSet',
                row:'Table1',
                repeatitems: true        
            },
            colNames:['Event Number','Description', 'Dispatch Group','Customers','Critical Customers','Feeder','Substation','Estimated Repair'],
            colModel:[
              {name:'EventNumber', index:'EventNumber', width:55, sortable:true, xmlmap:"EventNumber"},
              {name:'Description', index:'Description', width:80, sortable:false, xmlmap:"Description"},
              {name:'DispatchGroup', index:'DispatchGroup', width:55, sortable:true, xmlmap:"DispatchGroup"},
              {name:'Customers', index:'Customers', width:55, sortable:true, xmlmap:"Customers"},
              {name:'CriticalCustomers', index:'CriticalCustomers', width:55, sortable:true, xmlmap:"CriticalCustomers"},
              {name:'Feeder', index:'Feeder', width:55, sortable:true, xmlmap:"Feeder"},
              {name:'Substation', index:'Substation', width:55, sortable:true, xmlmap:"Substation"},
              {name:'EstimatedRepair', index:'EstimatedRepair', width:55, sortable:false, xmlmap:"EstimatedRepair"} ],
            pager:jQuery('#pager'),
            rowNum:10,
            rowList:[10,20,30],
            viewrecords:true,
            imgpath:'themes/green/images',
            caption:'My first grid'
          });
     });

My page gives a error of "Object doesn't support this property or method"

16/04/2009
10:57
Avatar
cshan
New Member
Members
Forum Posts: 1
Member Since:
15/04/2009
sp_UserOfflineSmall Offline

Hello,

  If you had implemented the JQGrid with Asp.net (c#) can you pl. give the samples of both asp.net side and JQuery. I am newbie to JQuery and JQGrid, and find it hard to understand how the  add, delete, search works. I undertstood from various forum responses that we need to use server side. I implemented a server side call to get all the records from database. But to update/edit, search and sort, do we still need to implement server side and provide separate url for each call.

   Pl. help.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

Currently Online:
19 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information