jQWidgets Forums
jQuery UI Widgets › Forums › Grid › jqx.dataAdapter
Tagged: jqx.dataAdapter
This topic contains 6 replies, has 2 voices, and was last updated by UJanke 12 years, 7 months ago.
-
Authorjqx.dataAdapter Posts
-
Since the jqx.dataAdapter is mission his own Forum ill try to post it here.
First all your Widgetsare working fine. But with that dataAdapter i go a bit overboard. Aslo possibe i’m jut to stpid
As long i use it thgther with grid, combo and so on all works fine. If i only use .databind() i run in problems…Here my code so far. ( GetData in code behind i left out)
<WebMethod()> _<ScriptMethod(UseHttpGet:=True, ResponseFormat:=ResponseFormat.Xml)> _ Public Shared Function GetAudit() As String Dim query As String = "SELECT * FROM dbo.MST_SAJob_Packages" Dim cmd As New SqlCommand(query) ' Populate the DataSet. Dim data As DataSet = GetData(cmd) ' return the Customers table as XML. Dim writer As New System.IO.StringWriter() data.Tables(0).WriteXml(writer, XmlWriteMode.WriteSchema, False) Return writer.ToString() End Function
source = { datatype: "xml", type:"POST", datafields: [ { name: 'SSISPackage' }, { name: 'SAJob' } ], data: userData, async: false, record: 'Table', url: 'Default.aspx/GetAudit' }; var dataAdapter = new $.jqx.dataAdapter(source, { contentType: 'application/json; charset=utf-8', loadComplete: function () { var length = dataAdapter.records.length; var records = dataAdapter.records; var record = records[0]; alert(record.SAJob); alert(length); } , error: function (xhr, status, error) { alert(JSON.stringify(xhr)); }, } ) dataAdapter.dataBind();
So far so good, i get a result and all is fine. But as soon i want to add an parameter cuz i dont want to pull the whole table
<WebMethod()> _<ScriptMethod(UseHttpGet:=True, ResponseFormat:=ResponseFormat.Xml)> _ Public Shared Function GetAudit(SSIPackage As String) As String Dim query As String = "SELECT * FROM dbo.MST_SAJob_Packages" Dim cmd As New SqlCommand(query) ' Populate the DataSet. Dim data As DataSet = GetData(cmd) ' return the Customers table as XML. Dim writer As New System.IO.StringWriter() data.Tables(0).WriteXml(writer, XmlWriteMode.WriteSchema, False) Return writer.ToString() End Function
$(document).ready(function () { var userData = new Object(); userData.SSIPackage = "6310" source = { datatype: "xml", type:"POST", datafields: [ { name: 'SSISPackage' }, { name: 'SAJob' } ], data: userData, async: false, record: 'Table', url: 'Default.aspx/GetAudit' }; var dataAdapter = new $.jqx.dataAdapter(source, { contentType: 'application/json; charset=utf-8', loadComplete: function () { var length = dataAdapter.records.length; var records = dataAdapter.records; var record = records[0]; alert(record.SAJob); alert(length); } , error: function (xhr, status, error) { alert(JSON.stringify(xhr)); }, } ) dataAdapter.dataBind(); });
I dont get any result. Also it never runs into the code behind part. If i do the same togther with the grid it works again. just if i use .databind() it wont work. Well hornestly i think somewaht i left out. But i need to pull data for an edit screen. So how to fill up that data adapeter with the needed fields?
Best regards from Munich
U. JankeHi UJanke,
See this help topic which shows how to add parameters: jquery-grid-extra-http-variables.htm.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comOk i can pass Parameter
with$.ajax({
type: “POST”,
url: “Default.aspx/WebMethodName”,
data: “{‘featureClass’: ‘P’}”,
contentType: “application/json; charset=utf-8”,
dataType: “json”
});That works fine. But if i try the same with a WebMethod on my aspx – Page Codebehind to recive at last Data from SQL Server into the jqxdataapter i fail, and i realy shouldn’t cuz i just try to convince the whole company from jquery and jqwidgets….
Perhaps the reason that i expect xml as answer?
_
_
Public Shared Function GetAudit(featureClass As String) As StringI that case i try:
source = {
datatype: “xml”,
type: “POST”,
datafields: [
{ name: ‘SSISPackage’ },
{ name: ‘SAJob’ }
],
data: “{‘featureClass’: ‘P’}”,
async: false,
record: ‘Table’,
url: ‘Default.aspx/GetAudit’
};var dataAdapter = new …..
.databind()
…
…
…And my Debugger says you never ever reach this line….
Best Regards,
U.JankeHi UJanke,
There are several help topics in the ASP .NET Integration section of the help docs which demonstrate how to get data from SQL DB. Hope you find them helpful.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comDear Peter,
i was reading the ASP .NET Integration 1000 times.
and as long i bind the source to one of the Widget all goes well.As soon i try to use
var dataAdapter = new $.jqx.dataAdapter(source, {….})
dataAdapter.dataBind();and the WebMethod needs parameters, the WebMethod will not be triggerd.
If i bind the grid all works fine, with parameters or not.
If i use dataAdapter.dataBind(); without parameters also all works fine
If i use dataAdapter.dataBind(); with parameters …. FAILThe strange part, iof i set a berakpoint at the WebMethod it never ever hits.
Best Regards,
U.JankeHi UJanke,
To override the parameters sent to the server, you can use the formatdata function of the source object.
var source ={ datatype: "jsonp", datafields: [ { name: 'countryName' }, { name: 'name' }, { name: 'population', type: 'float' }, { name: 'continentCode' } ], url: "http://ws.geonames.org/searchJSON", data: { featureClass: "P", style: "full", maxRows: 50 }, formatdata: function (data) { return "my data"; }};
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comDear Peter,
thanks for your help. But anyway how i’m doing
as soon i change:_
_
Public Shared Function GetCustomers() As Stringto:
_
_
Public Shared Function GetCustomers(sCustNo as String) As String
It dosnt work anymore with adapter.databind() . Even if i try all your examples.
I still wonder as long i try with the gird both methods are working.Well i can set first the paramter to
_
Public function SetParameter(sParameter as String)
myParameter =sParameter
End Functionand then…
_
_
Public Shared Function GetCustomers(sCustNo as String) As String
sSQL=”Select xxx from where parameter='” & sParameter & “‘”
….
….
End FunctionSeems a bit ugly, but it seems the only workaround for the moment….
-
AuthorPosts
You must be logged in to reply to this topic.