I have working application with dialog box. I would like to implement slickGrid (SG) in dialog for this application. I sow several posts related to this subject. Unfortunately I still did not get how to implement it in my case. I use partial view in dialog and my problem is I do not know how get data for SG in partial view.
I would appreciate any suggestions/help in this matter.
Here is my code:
View model
public class EatHabTransfer
{
public string Name { get; set; }
public string NDB_No { get; set; }
public Nullable<int> GrpTypeFlag { get; set; }
public string FdGrp_CD { get; set; }
public bool selected { get; set; }
}
==============
Controller:
public ActionResult TestDialog(string grpCD_name)
{
List<GetNamesGroup_1_Result> rfn = null;
List<GetNamesGroup_2_Result> gfn = null;
List<getNamesGroup_3_Result> pfn = null;
string[] ar2 = tst.Split('=');
string CD_grp = ar2[0];
List<EatHabTransfer> eht = new List<EatHabTransfer>();
if (ar2[1].Equals("1"))
{
rfn = dbFoods.GetNamesGroup_1 (CD_grp).ToList();
for (int i = 0; i < rfn.Count; i++)
{
eht.Add(new EatHabTransfer(rfn[i].Name.Trim(), rfn[i].NDB_No, null, rfn[i].FdGrp_CD));
}
}
else if (ar2[1].Equals("2"))
{
gfn = dbFoods.GetNamesGroup_2(CD_grp).ToList();
for (int i = 0; i < gfn.Count; i++)
{
eht.Add(new EatHabTransfer(gfn[i].Name.Trim(), gfn[i].NDB_No, null, gfn[i].FdGrp_CD.ToString()));
}
}
else if (ar2[1].Equals("3"))
{
pfn = dbFoods.GetNamesGroup_3(CD_grp).ToList();
for (int i = 0; i < pfn.Count; i++)
{
eht.Add(new EatHabTransfer(pfn[i].Name.Trim(), pfn[i].NDB_No, null, pfn[i].FdGrp_CD));
}
}
ViewBag.Title = eht.Count;
return PartialView("~/Views/Test/PartialTestDialog.cshtml", eht);
}
==========
Partial Vier:
@model IEnumerable<SgBsMVC4.Models.EatHabTransfer>
<body>
<label>@Html.DisplayNameFor(model => model.grpName)</label>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.grpName)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.grpName)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
</table>
</body>
=========
My dialog:
function dialogUP()
{
document.getElementById("dialogForm").innerHTML = '';
$("#dialogForm").dialog({
autoOpen: true,
//position: { my: "center", at: "top+70", of: window },
position: { my: "right+350 bottom-100" },
width: 490,
height: 570,
resizable: false,
title: foodSourceName +': '+ grpName,
modal: false,
open: function () {
var url = '@Url.Action("_PartialTestDialog", "Test" )';
url += '/?grpCD_name=' + grpCD + '='+ foodSourceType;
$(this).load(url);
},
buttons: {
"Add to table": function () {
add2table();
partialFree = 0;
$(this).dialog("close");
},
Cancel: function () {
partialFree = 0;
$(this).dialog("close");
}
}
});
}