How to show data based by field in master table?

Hi, can you give me example about this topic? I’m completely lost how to show data based by field (modal dialog) in master table?

Can you explain ‘show data based by field (modal dialog) in master table’? (There is no master table in modal dialog.)

Populate data in detail table based by field in master table, so far, i can show all data use server event->page rendering, but i’m completely lost how to filter data based by field in master table. I know the logic, but i don’t know where to put $_get and onchange.

  1. What did you mean by “(modal dialog)”?
  2. Are you using Master/Detail-Add or just Grid-Add of the detail table?
  3. Is the “field in master table” the primary key of the master table?
  4. Post your code in Page_Rendering for discussion.
  1. Checkbox → lookup table → modal dialog
  2. Master/Detail-Add
  3. No.
  4. row rendering btw, sorry, my bad.


function Row_Rendering()
{
    // Enter your code here
//if($this->PageID == "grid")
//{
$grid_count = $this->GridAddRowCount;
$grid_num = $this->GridCnt;

if(isset($this->RowIndex))
{
$grid_num = $this->RowIndex;
//only when we are dawing actual rows
if(($grid_count >= $grid_num) && is_int($grid_num) && ($grid_num >= 1))
{
$offseter = $grid_num - 1;
//get & set product details
$elobj=ExecuteRow("SELECT id_pesanan,id_barang, jumlah FROM vdetail pesanan WHERE limit 1 OFFSET $offseter");
$this->pesanan_id->CurrentValue =$elobj["id_pesanan"];
$this->nama_barang->CurrentValue =$elobj["id_barang"];
$this->qty->CurrentValue=$elobj["jumlah"];
}
}
}
}
1 Like

You meant Modal Lookup. Note that the user do modal lookup and select a value on the client side. The Master/Detail-Add page does not reload itself in such cases so you cannot use server event to populate detail grid. You need to use Ajax, see Lookup Table → Ajax by API and Client Scripts in the help file.

I have another question about populate data, let say i have data like this

Order_id || id_product || qty
123 || 2 || 1
123 || 1 || 2
123 || 5 || 7
124 || 2 || 1
124 || 3 || 3

how to determine total grid in detail table based by order_id? Ex: if i choose order_id 123 then row in detail table just 3. Can i use this code in page_load?

$this->GridAddRowCount = ExecuteScalar("select count(*) from vdetailpesanan where order_id = (i dont know what should i put in here)");

If the Order_id is the field that connected between master and detail table, then you may try this code in Page_Render server event that belongs to your detail table:$this->GridAddRowCount = ExecuteScalar("SELECT COUNT(*) FROM vdetailpesanan WHERE order_id = " . Container(“orders”)->Order_id->CurrentValue);Assume you’re using v2021, and the master table name is orders, and the field in your detail table that connected to the master table is Order_id.

Pandanwangiii wrote:

  1. Master/Detail-Add

arbei wrote:

Note that the user do modal lookup and select a value on the client side. The Master/Detail-Add page does not reload itself in such cases so you cannot use server event…