Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
3
Answers
[How] MVC multiple grid with different data
Bryan Gomez
7y
150
1
Reply
I need some help on how to achived the multiple grid in my mvc razor form with different data. Currently I only have 1 grid.
Here's my Model:
namespace
wmssoft_srm.Models
{
public
class
ServiceList
{
public
List<ServiceListData> GetData(DataTable oDT)
{
try
{
List<ServiceListData> slData =
new
List<ServiceListData>();
for
(
int
i = 0; i < oDT.Rows.Count; i++)
{
/*Parse date*/
string
date = oDT.Rows[i][
"ORDDATE"
].ToString();
string
result = DateTime.ParseExact(date,
"yyyyMMdd"
, CultureInfo.InvariantCulture).ToString(
"yyyy-MM-dd"
);
ServiceListData sl =
new
ServiceListData();
sl.date = Convert.ToDateTime(result);
sl.so_no = oDT.Rows[i][
"ORDNUMBER"
].ToString();
sl.serial = oDT.Rows[i][
"SERIAL"
].ToString();
sl.status = oDT.Rows[i][
"STATUS"
].ToString();
sl.technician = oDT.Rows[i][
"TECH"
].ToString();
slData.Add(sl);
}
return
slData;
}
catch
(Exception)
{
throw
new
NotImplementedException();
}
}
}
public
class
ServiceListData
{
public
DateTime date {
get
;
set
; }
public
string
so_no {
get
;
set
; }
public
string
serial {
get
;
set
; }
public
string
status {
get
;
set
; }
public
string
technician {
get
;
set
; }
}
public
enum
Status
{
Open,
Close
}
}
And in my controller:
My problem is that, how can I call the 2nd grid from my controller?
public
ActionResult Index()
{
WCF_Service.InterfaceClient wmsSR =
new
WCF_Service.InterfaceClient();
DataSet dsl =
new
DataSet();
DataSet dsO =
new
DataSet();
string
a =
"ValidateCredentials"
;
string
b =
"~~ ~~ ~~"
;
b = wmsSR.fCallService(
"GetServiceList"
, b,
ref
dsl,
ref
dsO);
if
(b ==
"OK ~~"
)
{
if
(dsO.Tables[0].Rows.Count > 0)
{
DataTable oDT =
new
DataTable();
oDT = dsO.Tables[0];
wmssoft_srm.Models.ServiceList slData =
new
Models.ServiceList();
var myList = slData.GetData(oDT);
return
View(myList);
}
}
return
View();
}
Also this is my View, the allJobs is my 2nd grid. The myJobs is my 1st grid which is working as expected based from my controller.
@model List<wmssoft_srm.Models.ServiceListData>
@using GridMvc.Html
<
div
id
=
"Tabs"
role
=
"tabpanel"
>
<!-- Nav tabs -->
<
ul
class
=
"nav nav-tabs"
role
=
"tablist"
>
<
li
class
=
"active"
>
<
a
href
=
"#tabs-1"
aria-controls
=
"tabs-1"
role
=
"tab"
data-toggle
=
"tab"
>
My Jobs
</
a
>
</
li
>
<
li
>
<
a
href
=
"#tabs-2"
aria-controls
=
"tabs-2"
role
=
"tab"
data-toggle
=
"tab"
>
All Jobs
</
a
>
</
li
>
<
li
>
<
a
href
=
"#tabs-3"
aria-controls
=
"tabs-3"
role
=
"tab"
data-toggle
=
"tab"
>
Unallocated Jobs
</
a
>
</
li
>
</
ul
>
<!-- Tab panes -->
<
div
class
=
"tab-content"
style
=
"padding-top: 20px"
>
<
div
role
=
"tabpanel"
class
=
"tab-pane active"
id
=
"tabs-1"
>
@Html.Grid(Model).Columns(
columns
=
>
{
columns.Add(
foo
=
>
foo.date).Titled("Date").SetWidth(30).Sortable(true); /*BTG 11/10/2017 - old .Filterable(true)*/
columns.Add(
foo
=
>
foo.so_no).Titled("SO No.").SetWidth(30).Sortable(true); //.Filterable(true);
columns.Add(
foo
=
>
foo.serial).Titled("Serial").SetWidth(30).Sortable(true); //.Filterable(true);
columns.Add(
foo
=
>
foo.status).Titled("Status").SetWidth(30).Sortable(true); //.Filterable(true);
columns.Add(
foo
=
>
foo.technician).Titled("Technician").SetWidth(30).Sortable(true); //.Filterable(true);
}).WithPaging(5).Named("myJob")
</
div
>
<
div
role
=
"tabpanel"
class
=
"tab-pane"
id
=
"tabs-2"
>
@Html.Grid(Model).Columns(
columns
=
>
{
columns.Add(
foo
=
>
foo.date).Titled("Date").SetWidth(30).Sortable(true); /*BTG 11/10/2017 - old .Filterable(true)*/
columns.Add(
foo
=
>
foo.so_no).Titled("SO No.").SetWidth(30).Sortable(true); //.Filterable(true);
columns.Add(
foo
=
>
foo.serial).Titled("Serial").SetWidth(30).Sortable(true); //.Filterable(true);
columns.Add(
foo
=
>
foo.status).Titled("Status").SetWidth(30).Sortable(true); //.Filterable(true);
columns.Add(
foo
=
>
foo.technician).Titled("Technician").SetWidth(30).Sortable(true); //.Filterable(true);
}).WithPaging(5).Named("allJobs")
</
div
>
</
div
>
</
div
>
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
How to disable View Page Source in Browser?
How to Send mail automatically thru external javascript ?