[CLOSED] Store problem with jsonp proxy when insert, update,delete

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Store problem with jsonp proxy when insert, update,delete

    Hello, in the code example i have a store with setup for server calls with proxy jsonp.

    The problem is that when the sync command executes the server calls executed ok but the header params are not in array but it is different param every field.
    I made the same example with extjs and when jsonwriter has the encode=true the fields come in server inside array.

    Some help please ?

        <ext:Store ID="store_users" runat="server" AutoSync="false" RemoteSort="true" RemoteFilter="true" PageSize="20"  >
            <Model>
              <ext:Model ID="model_users" runat="server" IDProperty="UserId">
                  <Fields>
                      <ext:ModelField Name="UserId" Type="String" />
                      <ext:ModelField Name="UserLoginName" Type="String" />
                      <ext:ModelField Name="UserLastName" Type="String" />
                      <ext:ModelField Name="UserFirstName" Type="String" />
                      <ext:ModelField Name="UserPersonName" Type="String" />
                      <ext:ModelField Name="UserEMail" Type="String" />
                      <ext:ModelField Name="UserActive" Type="Boolean" />
                      <ext:ModelField Name="UserDeleted" Type="Boolean" />
                      <ext:ModelField Name="UserDomain" Type="String" />
                      <ext:ModelField Name="UserLastNameGR" Type="String" />
                      <ext:ModelField Name="UserFirstNameGR" Type="String" />
                      <ext:ModelField Name="UserDateCreated" Type="Date" />
                  </Fields>
                  <Proxy>
                    <ext:JsonPProxy >
                      <API Read="users.ashx" Create="users.ashx" Update="users.ashx" Destroy="users.ashx"></API>
                      <Reader>
                        <ext:JsonReader Root="data" SuccessProperty="success" MessageProperty="message" TotalProperty="total" />
                      </Reader>
                      <Writer>
                        <ext:JsonWriter Encode="true" WriteAllFields="false" Root="data" />
                      </Writer>
                    </ext:JsonPProxy>
                  </Proxy>
              </ext:Model>
            </Model>
        </ext:Store>
    this is the firebug params for the destroy call

    UserActive false
    UserDateCreated 2008-01-01T00:00:00
    UserDeleted false
    UserDomain SLG
    UserEMail test
    UserFirstName test
    UserFirstNameGR
    UserLastName test
    UserLastNameGR ΑΒΓΔΕΖΗΘ
    UserLoginName test
    UserPersonName test test
    _dc 1374587993320
    action destroy
    callback Ext.data.JsonP.callback2
    records UserId=57CE6801E1DF08408026640E71405CDA

    and the correct with extjs for destroy is:

    _dc 1374588593034
    callback Ext.data.JsonP.callback2
    data {"UserId":"57CE6801E1DF08408026640E71405CDA"}
    Last edited by Daniil; Jul 25, 2013 at 7:32 AM. Reason: [CLOSED]
  2. #2
    Hi @mtsig,

    Welcome to the Ext.NET forums!

    Please post the ExtJS Store configuration code which works as you need.

    Could you also clarify why you are using JsonPProxy? The URLs do not look cross-domain.
    Last edited by Daniil; Jul 23, 2013 at 4:48 PM.
  3. #3
    Hello,

    I have no specific reason to use jsonp proxy. I just found it in example and use it.

    The code of extjs that works :

    		Ext.define('model_users', {
    			extend: 'Ext.data.Model',
    			idProperty: 'UserId',  // PRIMARY KEY - A MUST OTHERWISE UPDATE AND DELETE IS NOT WORKING
    			fields: [	{	name: 'UserId', type: 'string' },
    								{	name: 'UserLoginName', type: 'string'	},
    								{	name: 'UserLastName', type: 'string'	},
    								{	name: 'UserFirstName', type: 'string'	},
    								{	name: 'UserPersonName', type: 'string'	},
    								{	name: 'UserEMail', type: 'string'	},
    								{	name: 'UserActive', type: 'bool'	},
    								{	name: 'UserDeleted', type: 'bool'	},
    								{	name: 'UserDomain', type: 'string'	},
    								{	name: 'UserLastNameGR', type: 'string'	},
    								{	name: 'UserFirstNameGR', type: 'string'	},
    								{	name: 'date2', type: 'date' }
    							]});
    
    
    				
    		var store_users = Ext.create('Ext.data.Store',{
    			pageSize: 20, // PAGING SIZE 
    			model: 'model_users',
    			remoteSort: true, // REMOTE SORTING is enabled and controlled from php
    			remoteFilter: true, // REMOTE FILTERING is enabled and controlled from php
    			autoLoad: true,   // autoload = true to load data when page is loading first time 
    			autoSync: false,  // autosync = false, the button save do all the work
    			
    			listeners:
    							{
    								beforeLoad: function()
    								{
    									var grid = Ext.getCmp("my_grid");
    									grid.setLoading({ msg: "" } );
    								},
    								load: function()
    								{
    									var grid = Ext.getCmp("my_grid");
    									grid.setLoading(false);
    								}
    							},
    			proxy: 	{
    								type: 'jsonp', // JSONP TYPE OF proxy
    								api:
    									{
    										read:    'app.php/read',
    										create:  'app.php/insert',
    										update:  'app.php/update',
    										destroy: 'app.php/delete',
    										headers: { 'Content-Type': 'application/json; charset=UTF-8' }
    									},
    								reader: 
    									{	
    										type: 'json',
    										successProperty: 'success',
    										root: 'data',
    										totalProperty: 'total',
    										messageProperty: 'message'
    									},
    								writer: 
    									{	
    										type: 'json',
    										writeAllFields: false,
    										root: 'data',
    										encode: true // A MUST, OTHERWISE INSERT and UPDATE do not send to server as array
    									},
    								listeners:
    									{
    										exception: function(proxy, response, operation) // EXCEPTION IN ERROR
    											{
    												Ext.MessageBox.show({ title: 'Server Error', msg: operation.getError(), icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK });
    											}	
    									}
    							}
    			});
  4. #4
    Thank you.

    Please try to replace
    <ext:JsonPProxy>
    with
    <ext:AjaxProxy Json="true">
    Last edited by Daniil; Jul 24, 2013 at 2:07 PM.
  5. #5
    Many thanks

    It works as it should with AjaxProxy.

    With json why not ? Is it a bug, just to know


    Quote Originally Posted by Daniil View Post
    Thank you.

    Please try to replace
    ext:JsonPProxy>
    with
    <ext:AjaxProxy Json="true">
  6. #6
    Not sure. Please try this with a JsonPProxy.

    <ext:JsonPProxy>
        <API Read="users.ashx" Create="users.ashx" Update="users.ashx" Destroy="users.ashx">
            <CustomConfig>
                <ext:ConfigItem Name="headers" Value="{ 'Content-Type': 'application/json; charset=UTF-8' }" Mode="Raw" />
            </CustomConfig>
        </API>
        ...
    Does it work as needed?
  7. #7
    No the same thing. I added to grid two rows and press the save (sync) button.
    Below is the header params from the insert request.
    The strange thing is that the writer has the property Root="data" but in the header params says records.

    UserActive false
    UserActive false
    UserDateCreated
    UserDateCreated
    UserDeleted false
    UserDeleted false
    UserDomain
    UserDomain
    UserEMail
    UserEMail
    UserFirstName
    UserFirstName
    UserFirstNameGR UserId=
    UserFirstNameGR
    UserLastName
    UserLastName
    UserLastNameGR
    UserLastNameGR
    UserLoginName
    UserLoginName
    UserPersonName
    UserPersonName
    _dc 1374672640520
    action create
    callback Ext.data.JsonP.callback2
    records UserId=

    This is the correct header params request on insert with Ajaxproxy with two records added.

    _dc 1374672871807
    action create
    data [{"UserLoginName":"","UserLastName":"","UserFirstNa me":"","UserPersonName":"","UserEMail":"","UserAct ive":false,"UserDeleted":false,"UserDomain":"","Us erLastNameGR":"","UserFirstNameGR":""},{"UserLogin Name":"","UserLastName":"","UserFirstName":"","Use rPersonName":"","UserEMail":"","UserActive":false, "UserDeleted":false,"UserDomain":"","UserLastNameG R":"","UserFirstNameGR":""}]

    Quote Originally Posted by Daniil View Post
    Not sure. Please try this with a JsonPProxy.

    <ext:JsonPProxy>
        <API Read="users.ashx" Create="users.ashx" Update="users.ashx" Destroy="users.ashx">
            <CustomConfig>
                <ext:ConfigItem Name="headers" Value="{ 'Content-Type': 'application/json; charset=UTF-8' }" Mode="Raw" />
            </CustomConfig>
        </API>
        ...
    Does it work as needed?
  8. #8
    Does this help?
    <ext:JsonWriter ... AllowSingle="true" />
  9. #9
    Sorry i checked AllowSingle true and false but the same behavior !!


    Quote Originally Posted by Daniil View Post
    Does this help?
    <ext:JsonWriter ... AllowSingle="true" />
  10. #10
    Seems I don't see any more difference between the ExtJS configuration code and the Ext.NET one.

    By the way, what ExtJS/Ext.NET versios are you testing with?
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] JSONP Proxy
    By gs_user in forum 2.x Legacy Premium Help
    Replies: 10
    Last Post: Apr 24, 2013, 8:23 AM
  2. Replies: 1
    Last Post: Apr 13, 2013, 1:31 AM
  3. [CLOSED] Insert, Update, Delete in CalendarPanel using ObjectDataSource
    By asiaesolutions in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Feb 21, 2013, 11:53 AM
  4. Replies: 0
    Last Post: Sep 02, 2010, 3:58 AM
  5. Replies: 0
    Last Post: Jun 10, 2010, 1:18 AM

Posting Permissions