jQuery UI Widgets Forums Plugins Data Adapter adapter and menu problem with JSON

Tagged: , , , ,

This topic contains 1 reply, has 2 voices, and was last updated by  Martin 1 year, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • adapter and menu problem with JSON #101231

    Javier Hernandez
    Participant

    Hi, my problem is, my menu show only data parentid -1 and not show parent-child.

    This is my code…

    
    $('#MainWindow').jqxWindow({
          autoOpen: false,
          isModal: true,
          width: "100%",
          height: "100%",
          draggable: false,
          resizable: false,
          theme: theme,
          initContent: function ()
          {
            var data = $.fn.fQuery2JSon("db-php/","main-menu.php",LevelUser.toString().trim());
            var menuData =
            {
                datatype: "json",
                datafields: [
                    { name: 'id', type: 'int' },
                    { name: 'text', type: 'string' },
                    { name: 'parentid', type: 'int' },
                    { name: 'subMenuWidth', type: 'string' },
                    { name: 'level', type: 'int' }
                ],
                id: 'id',
                localdata: data
            };
            var DatMenu = new $.jqx.dataAdapter(menuData);
            DatMenu.dataBind();
            MainMenu = DatMenu;
    
            var records = MainMenu.getRecordsHierarchy('id', 'parentid','items', [{ name: 'text', map: 'label'}]);
    
            $('#MainMenu').jqxMenu({ source: records, height: 30,  width: '100%' ,theme:theme});
    
          }
      });
    

    my data :
    Data return for getRecordsHierarchy
    (3) […]
    ​0: Object { id: 3, text: “Herramientas”, parentid: -1, … }
    ​1: Object { id: 4, text: “Mi Cuenta”, parentid: -1, … }
    ​2: Object { id: 5, text: “Acerca de …”, parentid: -1, … }

    my data return for php :
    {…}
    ​_bindingUpdate: Array []
    ​_downloadComplete: Array []
    ​_options: Object { }
    ​_source: Object { datatype: “json”, id: “id”, recordstartindex: 0, … }
    ​addrow: null
    ​cache: false
    ​cachedrecords: Array(9) [ {…}, {…}, {…}, … ]
    ​deleterow: null
    ​filter: null
    ​koSubscriptions: Array []
    ​loadedData: Array(9) [ {…}, {…}, {…}, … ]
    ​mapChar: “>”
    ​originaldata: Array(9) [ {…}, {…}, {…}, … ]
    ​pageable: false
    ​pagenum: 0
    ​pagesize: 0
    ​recordids: Array(52) [ <3 empty slots>, {…}, {…}, … ]
    ​records: Array(9) [ {…}, {…}, {…}, … ]
    ​totalrecords: 9
    ​unboundmode: false
    ​updaterow: null
    ​virtualmode: false
    ​<prototype>: Object { getrecords: getrecords()
    , beginUpdate: beginUpdate(), endUpdate: endUpdate(), … }

    adapter and menu problem with JSON #101248

    Martin
    Participant

    Hello Javier Hernandez,

    I’ve made a demo Example with the exact code that you provided.
    It doesn’t seem to have an issue. The menu is displayed as it should with the children data as sub menus.

    If you are getting a different result, the reason might be in the format of your php data.

    Best Regards,
    Martin

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.