This is a migrated thread and some comments may be shown as answers.

[Solved] get ParentGroup using jQuery

2 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
erick
Top achievements
Rank 1
erick asked on 06 Jul 2011, 04:14 AM
hi all, need help on javascript or jQuery

i have this master/detail like in attachment

when i create new one, it need the value for "ParentID" in this case "A/P Return"..how to get it then i can pass it to my Controller
here is myController action, it's populate correctly just missing the ObjectType value

[GridAction]
        public ActionResult _insertDetail(string objectType)
        {
            myOBJ detail = new myOBJ();
            if (TryUpdateModel(detail))
            {
                using (dbEntities db = new dbEntities())
                {
                    int lastNo = db.myOBJ.Count() < 1
                        ? 0
                        : db.myOBJ.Where(d => d.ObjectType == detail.ObjectType).Max(d => d.Line);
 
                    detail.Line = lastNo + 1;
 
                    db.AddTomyOBJ(detail);
                    db.SaveChanges();
                }
            }
 
            return View(new GridModel(getNumberingDetails(detail.ObjectType)));
        }

any insight?

thx,
erick

2 Answers, 1 is accepted

Sort by
0
erick
Top achievements
Rank 1
answered on 06 Jul 2011, 05:56 AM
already try from other thread but still no luck
var parentGrid = $("#ParentGrid").data("tGrid");
 var parentRow = $(this).closest("tr");
 var parentDataItem = parentGrid.dataItem(parentRow);
 
 e.values.OrderID = parentDataItem.OrderID; // values is sent to the server.
0
erick
Top achievements
Rank 1
answered on 06 Jul 2011, 08:59 AM
found the solution, no need using jQuery..

just pass along the ID as parameter in .Insert method
.DataBinding(dataBinding => dataBinding.Ajax()
        .Insert("_insertDetail", "Numberings", new { objectType = "<#= ObjectType #>" })
       )

need 2 days :(
thx,
erick
Tags
Grid
Asked by
erick
Top achievements
Rank 1
Answers by
erick
Top achievements
Rank 1
Share this question
or