TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Arvind Chourasiya
NA
933
134.3k
bind nodes and leafnodes dynamically in Exapandable listview
Oct 7 2016 3:18 AM
Hii C#Guys,
i need to bind menus and submenus dynamically in Expandable listview, im getting data from API's in this format
[
{
"applicationid"
: 24347,
"applicationname"
:
"Timetable Staff"
,
"ParentApplicationId"
: 24444,
"pagelink"
:
"~/Web/Reports/TimeTableStaff.aspx"
,
"PageName"
:
"Reports/TimeTableStaff"
,
"sortorder"
:
null
,
"IconCD"
:
null
},
{
"applicationid"
: 24875,
"applicationname"
:
"Question Bank-Scholastic"
,
"ParentApplicationId"
: 24438,
"pagelink"
:
"~/Web/QuestionBank/SearchQuestions.aspx"
,
"PageName"
:
"QuestionBank/Search"
,
"sortorder"
:
null
,
"IconCD"
:
null
},
{
"applicationid"
: 24879,
"applicationname"
:
"Tests-Scholastic"
,
"ParentApplicationId"
: 24438,
"pagelink"
:
"~/Web/QuestionBank/QuestionPaperSearch.aspx"
,
"PageName"
:
"TestsScholastic/Search"
,
"sortorder"
:
null
,
"IconCD"
:
null
},
{
"applicationid"
: 34113,
"applicationname"
:
"Staff Leave Management"
,
"ParentApplicationId"
: 24439,
"pagelink"
:
"~/Web/LeaveManagement/LeaveManagementStaffList.aspx"
,
"PageName"
:
"LeaveManagementStaff/List"
,
"sortorder"
:
null
,
"IconCD"
:
null
},
{
"applicationid"
: 24276,
"applicationname"
:
"Subjects"
,
"ParentApplicationId"
: 24438,
"pagelink"
:
"~/Web/Course/CourseSearch.aspx"
,
"PageName"
:
"Course/Search"
,
"sortorder"
: 1,
"IconCD"
:
null
},}
like that i'm getting 100's of records, if any record have
parentid
null means that record parent only, and parent record
applicationid
is same as parentid in other record means that record is child
(
parent child relationship based on applicationid and parentid here
)
im using foreach loop to add all prent in one list
var response = SisApi.Get(
"Auth/getmenu"
,
out
issucsesParam, UserId);
Person pobj =
new
Person();
var person =
new
Person { applicationname =
""
, ParentApplicationId =
""
, applicationid =
""
};
var menu2 = JsonConvert.DeserializeObject<List<Person>>(response);
foreach
(var n
in
menu2)
{
if
(n.ParentApplicationId ==
null
)
{
ParentnodeNames.Add(n.applicationname);
}
}
if parentnodes list have 20 records say
Admin, Management, Library
i'm statically creating that many List<String> like
ListAdmin, ListManagement
to add relevent child records
below
foreach
(var r
in
menu2)
{
if
(r.ParentApplicationId ==
"24439"
|| r.applicationname ==
"Admin"
)
{
AdminList.Add(r.applicationname);
}
if
(r.ParentApplicationId ==
"24443"
|| r.applicationname ==
"Management"
)
{
ManagementList.Add(r.applicationname);
}
if
(r.ParentApplicationId ==
"24438"
|| r.applicationname ==
"Academics"
)
{
AcademicsList.Add(r.applicationname);
}
}
finally im adding all list in Dicationary
Dictionary<
string
, List<
string
>> childdata=
new
Dictionary<
string
,List<
string
>>();
entnodeNames.Contains(
"Admin"
))
childdata.Add(ParentnodeNames[0], AdminList);
if
(ParentnodeNames.Contains(
"Management"
))
childdata.Add(ParentnodeNames[1], ManagementList);
if
(ParentnodeNames.Contains(
"Academics"
))
childdata.Add(ParentnodeNames[2], AcademicsList);
and setting to listview.
here this my logic working fine for the same data if someone add more record in database my logic will fail i need to again modify my code and creating lists, please can anyone tell me the to add these menus dynamically
for reference purpose please see this demo
http://www.appliedcodelog.com/2016/06/expandablelistview-in-xamarin-android.html
thanks :)
Reply
Answers (
0
)
How to do any work on Button Long Press only in winform.
chatting proggramming