Page 1 of 1

change count master/detail

Posted: Mon Jan 16, 2023 2:06 am
by danilo.macri

hi guys, i want to change the detail count
I have three views:
tablemaster ( master)
table1 (detail)
table2all

I want in the detail counts of table one to count the data of the table2all view
I used the following code:
the ListOptions_Rendering() of tablemaster I entered

$this->table1_Count = ExecuteScalar("SELECT COUNT(*) FROM table2all");

it returns me this error:

C:\xampp\htdocs\detenuti\src\DbTableBase.php(561): Obsolete property: table1_Count, please use Container('table1')->Count.

why?


Re: change count master/detail

Posted: Mon Jan 16, 2023 8:20 am
by mobhar

Because the table1_Count property is deprecated. You should use Container('table1')->Count instead.

So, change this code:
$this->table1_Count = ExecuteScalar("SELECT COUNT(*) FROM table2all");

to:
Container('table1')->Count = ExecuteScalar("SELECT COUNT(*) FROM table2all");


Re: change count master/detail

Posted: Mon Apr 03, 2023 4:02 am
by danilo.macri

I inserted the code in the master table

function ListOptions_Rendering()
{

Container('tablemaster')->Count = ExecuteScalar("SELECT COUNT(*) FROM tableall");

}

I've enabled datail record count but I'm left with the original count, not the one in the table..... why?


Re: change count master/detail

Posted: Mon Apr 03, 2023 9:01 am
by mobhar

Try to put in ListOptions_Rendered server event.


Re: change count master/detail

Posted: Tue Apr 04, 2023 1:56 am
by danilo.macri

it does not work :(
do you have any other method to change the number of master / detail?


Re: change count master/detail

Posted: Tue Apr 04, 2023 9:09 am
by mobhar

It should work. It seems you are wrong to use master table name. It should be detail table name.

danilo.macri wrote:

Container('tablemaster')->Count = ExecuteScalar("SELECT COUNT(*) FROM tableall");

You should change tablemaster to your detail table name.


Re: change count master/detail

Posted: Thu May 04, 2023 4:02 am
by danilo.macri

I inspected the page code;

// "detail_pad_sicattpass"
    $opt = $this->ListOptions["detail_pad_sicattpass"];
    if ($Security->allowList(CurrentProjectID() . 'pad_sicattpass')) {
        $body = $Language->phrase("DetailLink") . $Language->TablePhrase("pad_sicattpass", "TblCaption");
        if (!$this->ShowMultipleDetails) { // Skip loading record count if show multiple details
            $detailTbl = Container("pad_sicattpass");
            $detailFilter = $detailTbl->getDetailFilter($this);
            $detailTbl->setCurrentMasterTable($this->TableVar);
            $detailFilter = $detailTbl->applyUserIDFilters($detailFilter);
            $detailTbl->Count = $detailTbl->loadRecordCount($detailFilter);
            $body .= " " . str_replace("%c", Container("pad_sicattpass")->Count, $Language->phrase("DetailCount"));
        }
        $body = "<a class=\"btn btn-default ew-row-link ew-detail" . ($this->ListOptions->UseDropDownButton ? " dropdown-toggle" : "") . "\" data-action=\"list\" href=\"" . HtmlEncode("PadSicattpassList?" . Config("TABLE_SHOW_MASTER") . "=padiglioceconta&" . GetForeignKeyUrl("fk_idpadiglione", $this->idpadiglione->CurrentValue) . "") . "\">" . $body . "</a>";
        $links = "";
        $detailPage = Container("PadSicattpassGrid");
        if ($links != "") {
            $body .= "<button type=\"button\" class=\"dropdown-toggle btn btn-default ew-detail\" data-bs-toggle=\"dropdown\"></button>";
            $body .= "<ul class=\"dropdown-menu\">" . $links . "</ul>";
        } else {
            $body = preg_replace('/\b\s+dropdown-toggle\b/', "", $body);
        }
        $body = "<div class=\"btn-group btn-group-sm ew-btn-group\">" . $body . "</div>";
        $opt->Body = $body;
        if ($this->ShowMultipleDetails) {
            $opt->Visible = false;
        }
    }

to change the count, in the master table I inserted this code:

/ /ListOptions Rendering event
public function listOptionsRendering()
{
Container("pad_sicattpass")->Count = ExecuteScalar("SELECT COUNT(*) FROM anagraficadetenuti");
}

this doesn't work..... do you know why?


Re: change count master/detail

Posted: Thu May 04, 2023 9:15 am
by mobhar

Are you sure pad_sicattpass is the detail table name?


Re: change count master/detail

Posted: Fri May 05, 2023 2:07 am
by danilo.macri

Yes, this is the code that automatically generates phpmaker2023... I should change the value of

$body .= "&nbsp;" . str_replace("%c", Container("pad_sicattpass")->Count, $Language->phrase("DetailCount"));


Re: change count master/detail

Posted: Fri May 05, 2023 5:44 pm
by mobhar

It seems you have to change it from the generated code for such case, since there are no server events that can override it.