HZGN.COM
welcome to my space
X
Welcome to:hzgn.com
Feng Shui | Graphic Design | Cosmetics | Causes and Organizations | Regulatory Compliance | Gadgets and Gizmos | Computer Forensics | Tools and Equipment | Related articles
Search:  
NAVIGATION - HOME
How To : Send Ext datastore to .Net dataset with XML
Published by: admin 2009-01-08
  • There are many examples of using the Ext xmlreader to get xml data into a datastore on the client, however I wanted to do the reverse and allow my CRUD application to update the modified datastore back to the server, updated with user changes.

    On the client I created a 'serialize' function to convert the datastore to XML, and then did an Ext.data.Connection to post the data to the server.

    SaveDStoServer :function(ds) {

    var prog = Ext.MessageBox.wait("Saving data to server");

    var ds_serialized= myscope.SerializeDS(ds);

    var serv= new Ext.data.Connection();
    serv.request({
    url: "Service.asmx/Savedata",
    params: {myID: 123, datastore:ds_serialized},
    method: 'POST',
    scope: this,
    callback: function(options, success, response){
    prog.hide();
    if (success){
    var xml = response.responseXML;
    }
    else {
    if( response.status == -1 )
    Ext.MessageBox.alert('Error on save','The server did not respond.')
    else
    Reports Validator 1.17::
    The XML dataset can also be consumed by SQL 2000 Reporting Services; however, this requires you to write a custom Data Processing Extension as SQL 2000
    http://wareseeker.com/Network-Internet/reports-validator-1.17.zip/1ffbc68c0
    HOME
    Ext.MessageBox.alert('Error on save',response.responseText)
    }
    }
    });
    },



    SerializeDS : function (ds) {

    var columns = ds.fields.keys; // get columns from data store

    var retdata ='';

    ds.each ( function (rec) {
    retdata +="";
    for (var i=0; i< columns.length; ++ i)
    retdata += "<" + columns[i] + ">" + rec.data[columns[i]] + ""
    retdata += "
    ";
    });

    retdata += "
    ";

    return ""+retdata;
    },


    On the server side web service method, I create an XML document, create a reader and then read into the dataset. I tried using 'XMLdatadocument' but if did not seem able to create a schema and had an empty dataset. This may not be the most efficient way but it seems to work well. As always, be aware of web service parameter verification to prevent SQL injection.

    [WebMethod]
    public String Savedata (String SchID, String datastore)
    {

    DataSet ds = new DataSet();
    XmlDocument doc = new XmlDocument();

    // Load the xml into an XmlDocument
    doc.LoadXml(datastore);
    StringReader sreader = new StringReader(doc.DocumentElement.OuterXml);

    ds.ReadXml(sreader);

    foreach (DataRow row in dsCraft.Tables[0].Rows)
    {
    System.Diagnostics.Debug.WriteLine(row[0] + " " + row[1]);
    }

    return "success";
    }


  • Something that you might look at is skipping the xml serialization alltogether.

    I send records to the a web service like this:


    var newData = ;
    Ext.getCmp("StructSettingsMain_AddMultiDivisions_gridDivisionA dd").getStore()
    .each(function(Record) {
    newData.push(Record.data);
    });
    // debugger;
    var r = Ext.Ajax.request( {
    method : "POST",
    url : "WebServices/CompanyStructureTree.asmx/DivisionMultiAdd",
    params : Ext.util.JSON.encode( {
    jsonDivList : Ext.util.JSON.encode(newData)
    }),
    async : false
    });


    On the server side, I do something like this:


    Public Function DivisionMultiAdd(ByVal jsonDivList As String) As String
    If Not Me.User.Identity.IsAuthenticated Then
    Return String.Empty
    End If
    Dim div As Object
    Dim mySerializer As New System.Web.Script.Serialization.JavaScriptSerializ er
    Dim DivList As Array = mySerializer.DeserializeObject(jsonDivList)

    For Each div In DivList
    Division.Insert(Code:=div.item("Code"), Name:=div.item("Name"), Product:=div.item("Product"), Number:=div.item("Number"), Rank:=div.item("Rank"))
    Next


  • You might also look at this thread (http://extjs.com/forum/showthread.php?p=34075) to see Animal's serialization fn.





  • Red Hat's Rough Recovery From CFO Exit
    Windows Live Finds a New, Pre-installed Home
    You are looking at:hzgn.com's How To : Send Ext datastore to .Net dataset with XML, click hzgn.com to home
    #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about How To : Send Ext datastore to .Net dataset with XML , Please add it free.
  • in the song tonight by the jonas brothers who sings which part
  • school uniform how do i show me and my style
  • can anyone teach me how to speak english
  • where can i find gossip girl inspired clothes with a low price tag
  • can you name some important protests
  • s are camo capris in or out
  • i need 2 no which radio station does the most jonas brothers meet and greet contests and the number
  • help me do you think i should talk to him about it
  • what is the plural of bluetooth
  • can i attend college and medical school at the same school
  • which of the jonas brothers do you think looks they gayest and the ugliest
  • which one is the worst break up on the msn or by email
  • which boy bad is better the jonas brothers or fall out boy
  • history hw help please
  •  
  • what would be the best associates degree to get
  • what is this i 039 ve never felt like this before
  • am i ugly pics included please read guys tooo
  • what can i do to see if my boyfriend is cheating on me
  • should i stay or should i go i cheated and he lied
  • which one of these is the right lyrics to sos by the jonas brothers
  • do the jonas brothers ever play at a place exept for chicago
  • which seats for the jonas brothers concerts are better
  • which one of the jonas brothers sings the song burnin up
  • which album are these jonas brothers 039 songs in
  • can you liken these ancient greek gods to present day celebrities
  • i want to be alice cullen for halloween what should i wear
  • why isn 039 t there mens size 35 waist pants
  • About us |Contact us |Advertisement |Site map |Exchange links
    Copyright© 2008hzgn.com All Rights Reserved