How to create a DocType like Material Request

I want to create a DocType which I named it as ‘Material Query’
First I created a DocType, whose name is ‘Material Query Item’,
and ‘Material Query Item’ has ‘Item Code’ which linked to Item, ‘Item Name’, and ‘Description’.
Then I create ‘Material Query’, and it has a Table field, which is linked to ‘Material Query Item’.

After that, I can new a ‘Material Query’, and I can add items in it.
But when I use ‘Material Request’, I select an item code, the ‘Item Name’ and ‘Description’ field will be autofilled automatically. The ‘Material Query’ what I made can not autofill like that.

What should I do to let it autofill?
Thank you!

Did you go through the app development tutorial?

https://frappe.io/docs

You can write it via the controller, see material_request.js and material_request.py

rmehta:

I’m so sorry, but after reading the tutorial and tracing the code of material_request.js and material_request.py,
I still can not understand how to write it via the controller.

Should I read what part of the tutorial? And can you give me a tip about tracing the code?
Thank you a lot!

@Chong_Phok_Sun did you build the library management app?