public JsonResult DynamicGridData(string sidx, string sord, int page, int rows, bool _search, string filters) { //note: a view is used here. This is because the we want to display the PUBLICATION_NETWORK field from the PUBLICATION_NETWORKS table //OID_PUBLISHER_ID field of the MEDIA_CAT_DIGITAL_PLCMNT table is hooked up to a combo box: ref method PublishersCombo() which feeds the combo box //if just the data from the MEDIA_CAT_DIGITAL_PLCMNT table was to be dispayed you could simply pass in the Placements class like so: //SearchHelper sh = new SearchHelper(new Placements(), ShapeGridRow); //display a view DynamicModel myview = new View_Placements_Publications(); jgridDisplayHelper sh = new jgridDisplayHelper(myview, ShapeGridRow); int pageIndex = Convert.ToInt32(page) - 1; int pageSize = rows; int totalRecords = tbl.Count(); //repository.TimeCards.Count(); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize); JsonResult mydata = sh.GetSearchResults(sidx, sord, page, rows, _search, filters); return mydata; }
//this is a delagate passed in to the SearchHelper. Each grid will want to display different columns-- you define the shape of the grid row here. //private static List<string> xxShapeGridRow(dynamic result) //{ // List<string> s = new List<string>(); // string a = ""; // string b = ""; // string c = ""; // string d = ""; // string e = ""; // string f = ""; // string g = ""; // string h = ""; // string i = ""; // string j = ""; // if (result.OID_MEDIA_CAT_DIGITAL_PLCMNT != null) // { // a = result.OID_MEDIA_CAT_DIGITAL_PLCMNT.ToString(); // } // if (result.MEDIA_GENRE.ToString() != null) // { // b = result.MEDIA_GENRE.ToString().ToString(); // } // if (result.MEDIA_PLAN_NAME != null) // { // c = result.MEDIA_PLAN_NAME.ToString(); // } // if (result.OID_PUBLISHER_ID != null) // { // d = result.OID_PUBLISHER_ID.ToString(); // } // if (result.PUBLICATION_NETWORK != null) // { // e = result.PUBLICATION_NETWORK.ToString(); // } // if (result.PLACEMENT_NAME != null) // { // f = result.PLACEMENT_NAME.ToString(); // } // if (result.PLACEMENT_CODE != null) // { // g = result.PLACEMENT_CODE.ToString(); // } // if (result.BEGIN_DATE != null) // { // h = Formatdate((result.BEGIN_DATE.ToString())); // } // if (result.END_DATE != null) // { // i = Formatdate(result.END_DATE.ToString()); // } // if (result.COST != null) // { // j = result.COST.ToString(); // } // s = new List<string>() { a, b, c, d, e, f, g, h, i, j }; // return s; //} //------ Sub Grid------------ public JsonResult SubGridData(string id) { string s = @" SELECT MEDIA_STATISTICS.* FROM MEDIA_CAT_DIGITAL_PLCMNT INNER JOIN MEDIA_STATISTICS ON MEDIA_CAT_DIGITAL_PLCMNT.PLACEMENT_CODE = MEDIA_STATISTICS.PLACEMENT_CODE and OID_MEDIA_CAT_DIGITAL_PLCMNT = "; s += id.ToString(); IEnumerable<dynamic> results = tbl.Query(s); DynamicModel myview = new View_Placements_Publications(); jgridDisplayHelper sh = new jgridDisplayHelper(ShapeSubGridRow); JsonResult myJasonResults = sh.GetJson(results, 0, 0, 0); return myJasonResults; }