Bruno17 / MIGX

MIGX for revo 2.2 and above
83 stars 78 forks source link

Problem with nested migxdb - wrong records count in cmp #329

Open dopeless opened 5 years ago

dopeless commented 5 years ago

Hi, I've got Migx Nested setup working, but there is a strange problem. In migxdb cmp everything work fine till I start to ad records to child cmp. As I add records to child cmp, records from parent cmp start to disapear. 111

As you can see, cmp sees all records, but shows not all of them. As I add more records to children cmp, less records are shown in parent cmp. If I set max records to display to some huge number, it works, but it's not a workaround. Btw, the search filter works. Even if there some records missing in grid, it shows them if I searc for them.

My shema

<?xml version="1.0" encoding="UTF-8"?>
<model package="productsapp" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
    <object class="Product" table="migx_pa_products" extends="xPDOSimpleObject" >
        <field key="title" dbtype="mediumtext" phptype="string" null="false" default=""/>
        <field key="longtitle" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
        <field key="alias" dbtype="varchar" precision="255" phptype="string" null="true" default=""/>
        <field key="intro" dbtype="mediumtext" phptype="string" null="false" default=""/>
        <field key="content" dbtype="mediumtext" phptype="string" null="false" default=""/>
        <field key="photo" dbtype="text" phptype="string" null="false" default=""/>

        <field key="galerie" dbtype="mediumtext" phptype="string" null="false" default=""/>

        <field key="cat_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default=""/>
        <field key="brand_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default=""/>

        <field key="published" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
        <field key="pos" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />

        <aggregate alias="ProdCategory" class="Category" local="cat_id" foreign="id" cardinality="one" owner="foreign"/>
        <aggregate alias="ProdBrand" class="Brand" local="brand_id" foreign="id" cardinality="one" owner="foreign"/>
    </object>

    <object class="Category" table="migx_pa_categories" extends="xPDOSimpleObject" >
        <field key="title" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>

        <field key="showonstart" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />

        <composite alias="CatProduct" class="Product" local="id" foreign="cat_id" owner="local" cardinality="many" />
        <composite alias="CatBrandcategory" class="Brandcategory" local="id" foreign="cat_id" owner="local" cardinality="many" />
    </object>

    <object class="Brand" table="migx_pa_brands" extends="xPDOSimpleObject" >
        <field key="title" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
        <field key="alias" dbtype="varchar" precision="255" phptype="string" null="true" default=""/>
        <field key="logo" dbtype="text" phptype="string" null="false" default=""/>
        <field key="content" dbtype="mediumtext" phptype="string" null="false" default=""/>
        <field key="published" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
        <composite alias="BrandProduct" class="Product" local="id" foreign="brand_id" owner="local" cardinality="many" />
        <composite alias="BrandBrandcategory" class="Brandcategory" local="id" foreign="brand_id" owner="local" cardinality="many" />
    </object>

    <object class="Brandcategory" table="migx_pa_brandcats" extends="xPDOSimpleObject" >
        <field key="cat_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default=""/>
        <field key="brand_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default=""/>

        <field key="content" dbtype="mediumtext" phptype="string" null="false" default=""/>

        <aggregate alias="BrandCatCategory" class="Category" local="cat_id" foreign="id" cardinality="one" owner="foreign"/>
        <aggregate alias="BrandCatBrand" class="Brand" local="brand_id" foreign="id" cardinality="one" owner="foreign"/>
    </object>
</model>

My parent config


{
  "formtabs":[
    {
      "MIGX_id":11,
      "caption":"Brand",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":35,
          "field":"title",
          "caption":"Name",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        },
        {
          "MIGX_id":36,
          "field":"alias",
          "caption":"Alias",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":2
        },
        {
          "MIGX_id":37,
          "field":"logo",
          "caption":"Logo",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"image",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":[
            {
              "MIGX_id":1,
              "context":"web",
              "sourceid":3
            },
            {
              "MIGX_id":2,
              "context":"mgr",
              "sourceid":3
            }
          ],
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":3
        },
        {
          "MIGX_id":38,
          "field":"content",
          "caption":"Content",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"richtext",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":4
        },
        {
          "MIGX_id":39,
          "field":"published",
          "caption":"Published",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"checkbox",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"ja==1",
          "default":1,
          "useDefaultIfEmpty":"0",
          "pos":5
        }
      ],
      "pos":1
    },
    {
      "MIGX_id":12,
      "caption":"Brand Kategorien",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":40,
          "field":"",
          "caption":"Brand Kategorien",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"migxdb",
          "validation":"",
          "configs":"pa_brandcats",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        }
      ],
      "pos":2
    }
  ],
  "contextmenus":"update||publish||unpublish",
  "actionbuttons":"addItem",
  "columnbuttons":"update||publish||unpublish",
  "filters":[
    {
      "MIGX_id":1,
      "name":"search",
      "label":"Suche",
      "emptytext":"Suche",
      "type":"textbox",
      "getlistwhere":{
        "title:LIKE":"%[[+search]]%"
      },
      "getcomboprocessor":"",
      "combotextfield":"",
      "comboidfield":"",
      "combowhere":"",
      "comboclassname":"",
      "combopackagename":"",
      "combo_use_custom_prefix":"0",
      "comboprefix":"",
      "combojoins":"",
      "comboparent":"",
      "default":""
    }
  ],
  "extended":{
    "migx_add":"",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"pa_brands",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "media_source_id":"",
    "multiple_formtabs":"",
    "multiple_formtabs_label":"",
    "multiple_formtabs_field":"",
    "multiple_formtabs_optionstext":"",
    "multiple_formtabs_optionsvalue":"",
    "actionbuttonsperrow":4,
    "winbuttonslist":"",
    "extrahandlers":"",
    "filtersperrow":4,
    "packageName":"productsapp",
    "classname":"Brand",
    "task":"",
    "getlistsort":"title",
    "getlistsortdir":"",
    "sortconfig":"",
    "gridpagesize":"",
    "use_custom_prefix":"0",
    "prefix":"",
    "grid":"",
    "gridload_mode":2,
    "check_resid":1,
    "check_resid_TV":"",
    "join_alias":"",
    "has_jointable":"yes",
    "getlistwhere":"",
    "joins":[
      {
        "alias":"BrandBrandcategory"
      }
    ],
    "hooksnippets":{
      "aftersave":"migxAlias"
    },
    "cmpmaincaption":"Brands",
    "cmptabcaption":"Brands",
    "cmptabdescription":"Brands verwalten",
    "cmptabcontroller":"",
    "winbuttons":"",
    "onsubmitsuccess":"",
    "submitparams":""
  },
  "columns":[
    {
      "MIGX_id":1,
      "header":"Id",
      "dataIndex":"id",
      "width":20,
      "sortable":"false",
      "show_in_grid":"0",
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":6,
      "header":"Alias",
      "dataIndex":"alias",
      "width":20,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":2,
      "header":"Name",
      "dataIndex":"title",
      "width":20,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":5,
      "header":"Published",
      "dataIndex":"published",
      "width":20,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"this.renderCrossTick",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    }
  ],
  "category":""
}

Child Config

{
  "formtabs":[
    {
      "MIGX_id":6,
      "caption":"Brand Kategorien",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":18,
          "field":"cat_id",
          "caption":"Kategorie",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"listbox",
          "validation":"required",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"@EVAL return $modx->runSnippet('mxdbBrandCatList',array('packageName'=>'productsapp','classname'=>'Category','objId'=>$modx->getOption('object_id',$_REQUEST,'undefined'),'coId'=>$modx->getOption('co_id',$_REQUEST,'undefined')));",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        },
        {
          "MIGX_id":19,
          "field":"content",
          "caption":"Content",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"richtext",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":2
        },
        {
          "MIGX_id":25,
          "field":"brand_id",
          "caption":"",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"none",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"@EVAL return $modx->getOption('co_id',$_REQUEST,'undefined');",
          "useDefaultIfEmpty":1,
          "pos":3
        }
      ],
      "pos":1
    }
  ],
  "contextmenus":"update||duplicate||remove",
  "actionbuttons":"addItem",
  "columnbuttons":"update||duplicate||remove",
  "filters":"",
  "extended":{
    "migx_add":"",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"pa_brandcats",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "media_source_id":"",
    "multiple_formtabs":"",
    "multiple_formtabs_label":"",
    "multiple_formtabs_field":"",
    "multiple_formtabs_optionstext":"",
    "multiple_formtabs_optionsvalue":"",
    "actionbuttonsperrow":4,
    "winbuttonslist":"",
    "extrahandlers":"",
    "filtersperrow":4,
    "packageName":"productsapp",
    "classname":"Brandcategory",
    "task":"",
    "getlistsort":"",
    "getlistsortdir":"",
    "sortconfig":"",
    "gridpagesize":"",
    "use_custom_prefix":"0",
    "prefix":"",
    "grid":"",
    "gridload_mode":2,
    "check_resid":"0",
    "check_resid_TV":"",
    "join_alias":"BrandCatBrand",
    "has_jointable":"yes",
    "getlistwhere":{
      "brand_id":"[[+object_id]]"
    },
    "joins":[
      {
        "alias":"BrandCatCategory"
      }
    ],
    "hooksnippets":"",
    "cmpmaincaption":"Brand Kategorien",
    "cmptabcaption":"Brand Kategorien",
    "cmptabdescription":"Brand Kategorien verwalten",
    "cmptabcontroller":"",
    "winbuttons":"",
    "onsubmitsuccess":"",
    "submitparams":""
  },
  "columns":[
    {
      "MIGX_id":1,
      "header":"Id",
      "dataIndex":"id",
      "width":"",
      "sortable":"false",
      "show_in_grid":"0",
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":2,
      "header":"Kategorie",
      "dataIndex":"BrandCatCategory_title",
      "width":25,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":3,
      "header":"Content",
      "dataIndex":"content",
      "width":75,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    }
  ],
  "category":""
}