If a single level score includes a score subkey, click on the score entry to pop up a new window with a list of all the rating subkeys for the current rating item, which is available for the user to manipulate. When the user is done, click OK to return to the parent form, all the results of the action in the subform, and take it to the parent form. Also, if the user clicks the rating item again, when the subform is popped, the result of the last action is bound to the corresponding action item.
The example described above involves data transfer between a parent-child form. There are, of course, many ways to implement this data transfer. Here is just a note of the method I used in this example. My approach is to construct a JSON-formatted string of action results when the subform clicks on the OK button, passing the JSON-formatted data to the parent form by calling the method on the parent form: opener. Method ().
The JSON data constructed in this example is similar to the following format:
{"MyData": [
{"BH": "", "LX": "1", "DF": "Ten", "BZ": "AAA"},
{"BH": "112", "LX": "2", "DF": "A", "BZ": "BBB"},
{"BH": "113", "LX": "2", "DF": "A", "BZ": "CCC"}
]}
The key points to be maintained here are BH: number; LX: type; DF: score; BZ: Remarks.
According to your own needs, you can increase the number of items you need to keep. This JSON data can be constructed in the foreground or in the background.
In this case, I was placed backstage. The code is as follows:
Copy Code code as follows:
StringBuilder Jsonbuilder = new StringBuilder ();
Jsonbuilder.append ("@{\");
Jsonbuilder.append ("MyData");
Jsonbuilder.append ("\": [");
int k = BH. Split (', '). Length + 1;
for (int i = 0; i < BH. Split (', '). Length; i++)
{
TEM + = "Update kh_pfx set DF = '" +encriptlib.encriptlib.encodecode (convert.todouble (DF). Split (', ') [i]. ToString (). Trim ()) + "',";
TEM = "BZ = '" +bz. Split (', ') [i]. ToString (). Trim () + "', Pfrxm = '" +session["XM"]. ToString () + "',";
TEM = "Pfrbh = '" +session["YHBH"]. ToString () + "', Pfrq = To_date ('" +datetime.now.toshortdatestring () + "', ' yyyy-mm-dd ')";
TEM = "Where BH = '" +BH. Split (', ') [i]. ToString (). Trim () + "'";
TEM = "卐"; This special symbol is used here to separate the SQL statement
Jsonbuilder.append ("{\" bh\ "):" + "\" "+ BH. Split (', ') [i]. ToString (). Trim () + "\" "+", "");
Jsonbuilder.append ("\" lx\): "+" \ "" + LX. Split (', ') [i]. ToString (). Trim () + "\" "+", "");
Jsonbuilder.append ("\" "df\": "+" \ "" + df.) Split (', ') [i]. ToString (). Trim () + "\" "+", "");
Jsonbuilder.append ("\" bz\): "+" \ "" + BZ. Split (', ') [i]. ToString (). Trim () + "\" "+"}, ");
}
if (TEM!= "")
{
Jsonbuilder.remove (jsonbuilder.length-1, 1);
Jsonbuilder.append ("]");
Jsonbuilder.append ("}");
Page.ClientScript.RegisterClientScriptBlock (GetType (), "CG", "<script>window.close" (); opener. GETZXDF (' zxdf "+ request.querystring[" BH "). ToString () + "', '" + PARENT_DF. Text.trim () + "', '" + jsonbuilder.tostring () + "', \" "+ tem +" \ ");</script>");
}
The "@" symbol prevents the escape character "\" from Disappearing after jsonbuilder.tostring ().
Invokes the GETZXDF () method of the parent form, passing the JSON data to the parent form.
The code that binds the JSON data when the subform is loaded is given below
Copy Code code as follows:
$ (function () {
Get JSON at load time and bind the score result
var obj = opener. Getjson ($ ("#txt_YCBH"). Val ());
if ($.trim (obj)!= "") {
obj = "(" + obj + ")";
obj = eval (obj);
var data = obj. MyData;
$.each (data, function (I, n) {
if (N.LX = = "1") {
Bind directly to classification
$ ("#lx" + n.bh). Siblings ("input"). EQ (0). val (N.DF);
$ ("#lx" + n.bh). Siblings ("input"). EQ (1). val (N.DF);
$ ("#lx" + n.bh). Parent (). Parent (). Next (). Children (). Children ("textarea"). Val (n.bz);
}
if (N.LX = = "2") {
Bindings for sorting options
$ ("#lx" + n.bh). Siblings ("Input:text"). EQ (1). val (N.DF);
$ ("#lx" + n.bh). Siblings ("Input:checkbox"). each (function () {
if ($.trim (this). val ()) = = $.trim (n.df)) {
$ (this). attr ("Checked", true);
}
});
$ ("#lx" + n.bh). Parent (). Parent (). Parent (). Next (). Children (). Children ("textarea"). Val (n.bz);
}
});
Opener. The Getjson () method is the method used to pass the JSON data to the subform on the parent form, as follows:
Copy Code code as follows:
A JSON string that retrieves the result of a child's score of the corresponding scoring item by number
function Getjson (P_BH)
{
$ ("#zxdf" + p_bh). Siblings ("input"). EQ (1). Val () Saves the JSON data that the subform passes to the parent form
Return $ ("#zxdf" + p_bh). Siblings ("input")-eq (1). Val ();
}