onclick action for a field in jEasyUI - datagrid

Using jEasyUI, I want to perform a Master/Detail lookup from a table.
Master
10
12
Detail
A B
---- -----
10 10, Cat,20
10 10, Cow,2
10 10, Chicken,11
12 12, Pig,2
When I click on 10 in the Master table dg1 above, I want Detail table dg2 to update to show B as belonging to A.
Can someone help to set up the onclick event which will do this?

Try this,(onclickrow event of dg1)
onClickRow:function(row){
var row = $("#dg1").datagrid('getSelected');
$('#dg2').datagrid({
url: 'getdetaildata.action?masterid='+row.id})
}

Related

Creating a check box dynamically

Can we create a checkbox dynamically on a window in progress? Actually i have created combo-box,frame,fill-in dynamically but not getting the idea how can I Create checkbox dynamically.
display "Example" skip(2) with frame a width 80.
define variable h as handle no-undo.
create toggle-box h assign
row = 2
column = 1
label = "hi there"
frame = frame a:handle
sensitive = true
visible = true
.
wait-for window-close of current-window.

Peoplesoft rowset

I'm new to peoplesoft. I need a help in understanding the rowset and I have a requirement where i have 3 levels.
On level 1 i have a checkbox and when I open a component the value of the checkbox on level 1 should be passed and display to the level 2 grid for all rows.
For example
level0 - record1
level1 - record2 (Scroll Area)
level2 - record3 (grid)
When i access the page it should have values like this
Record2.field1 = Y => Row1 Record3.field1 = Y
Row2 Record3.field1 = Y
Record2.field1 = N => Row1 Record3.field1 = N
I have written the code at level2 record.field rowinit peoplecode event. but the problem is the same record field is used in level 0 as well. Is there a way where I can avoid using for loop as there could be n number of rows in the grid which might create a performance issue during page opening.
Thanks in advance,
Rowinit will fire for each rows in the scroll. So if you have a loop in the rowinit, loop will execute for each row.
If you want the check box to be set only during the component load, you can add the peoplecode in Component PostBuild.
&rsLevel1 = GetLevel0()(1).GetRowSet(Scroll.Level1);
for &nCnt1 = 1 to &rsLevel1.activerowcount
&rsLevel2 = &rsLevel1(&nCnt1).GetRowset(Scroll.Level2);
for &nCnt2 = 1 to &rsLevel2.activerowcount
&rsLevel2(&nCnt2).Level2.Check_box.value = &rsLevel1(&nCnt1).Level1.Check_box.value
end-for;
end-for;

Select all rows that have ID in materialized path

I have this a tree structured table with a materialized path column (matpath).
The data looks like this:
ID MATPATH PARENT
---------------------
1 NULL NULL
2 1. 1
3 1.2. 2
4 1.2.3. 3
5 1.2. 2
6 1.2.3.4. 4
7 1.2.5. 5
etc
Given the ID, how can I get all elements that are above (one query) or below (anther query)?
For example, if the ID is 7, I want to select rows with IDs 1, 2 and 5 in addition to 7.
If the given ID is 3, select 1, 2 and 3. And so on.
Thank you.
First you have to decide if you want the trailing . on your materialized paths, I'll assume that you do want them because it will make life easier.
Something like this will get you the nodes below:
select id
from tree
where matpath like (
select matpath || id || '.%'
from tree
where id = X
)
Where X is the node you're interested in. Your tree looks like this:
1 --- 2 -+- 3 --- 4 --- 6
|
+- 5 --- 7
And applying the above query with a few values matches the diagram:
X | output
--+--------------
3 | 4, 6
7 |
2 | 3, 4, 5, 6, 7
Getting the nodes above a given node is easier in the client: just grab the matpath, chop off the trailing ., and then split what's left on .. SQLite's string processing support is rather limited, I can't think of a way to split the materialized path without trying to add a user-defined split function (and I'm not sure that the appropriate split could be added).
So two queries and a little bit of string wrangling outside the database will get you what you want.

Filtering in Oracle based on a group of values contained in a list of values

I have following two tables:
ID_PERSON NAME
-----------------
1 John
2 Joe
3 Peter
ID_PERSON ID_SPECIALIZATION
------------------------------
1 5
1 6
1 7
2 5
2 1
3 6
3 10
I need to filter data based on group of ids ID_SPECIALIZATION that will be provided. For example
I want to display only those persons who has specialization in 5 and 6 so it will return only first person. In ASP.NET Web form there will be two listboxes, left and right button, in first LB there will be all possible specializations and user will choose some of them to second LB as filtering options. I have no idea how to put this filtering condition in sql query. Thanks for help.
You could use the following:
SQL> SELECT p.id_person, p.NAME
2 FROM person p
3 JOIN person_spe s ON p.id_person = s.id_person
4 WHERE id_specialization IN (5, 6)
5 GROUP BY p.id_person, p.NAME
6 HAVING COUNT(*) = 2;
ID_PERSON NAME
---------- -----
1 John
One way to do it:
SELECT
ID_PERSON
, NAME
FROM
Person AS p
WHERE EXISTS
( SELECT *
FROM
PersonSpecialization AS ps
WHERE ps.ID_PERSON = p.ID_PERSON
AND ps.ID_SPECIALIZATION = 5
)
AND EXISTS
( SELECT *
FROM
PersonSpecialization AS ps
WHERE ps.ID_PERSON = p.ID_PERSON
AND ps.ID_SPECIALIZATION = 6
)
SELECT d1.id_person, d1.name FROM tbl_table1 d1
INNER JOIN tbl_table2 d1
ON d1.ID_PERSON=d2.ID_PERSON
WHERE ID_SPECILIZATION = ?
Theres the query but I'm not sure how asp.net works and passing in the value. It might be work looking up bind variables which allows you to use place holders in the sql which oracle then caches the query and just uses the values that you pass in at run tuime using EXECUTE IMMEDIATE.

MySQL - MyISAM multi-table delete (similar to ON CASCADE DELETE)

I'm looking to delete all entries that are referenced by a record, and all the children in different tables as well. If possible I'd like to use a multi-table delete statement as opposed to triggers.
For example
Table: forms
id var
1 foo
2 bar
Table 2: form_options
id form_id var
1 1 blah
2 2 hello
3 2 world
Table 3: form_options_info
id form_options_id var
1 3 world info
So given the above type of table struct, if I delete row 2 from forms that would delete row 2,3 from form_options as well as row 1 from form_options_info.
Maybee not the best solution, but it works:
DELETE FROM form_options_info, form_options, forms
USING forms INNER JOIN form_options INNER JOIN form_options_info
WHERE (form_options_info.form_options_id = form_options.id
AND form_options.form_id = forms.id
OR form_options.form_id = forms.id)
AND forms.id = 2;
...or just change the tables to InnoDB ;-)...

Resources