Display relationship in a devexpress grid












0















There are 2 Objects with a relationship between them.
Student and Class.
Each student has one or more classes. I want to show student in a grid control (devexpress winform) and I prefer not to use master detail. I want to show classes in a single column, like : class A-class B (in a single row) or split the row like merging.










share|improve this question























  • You could do this in your sql statement also, sql server has the stuff statement you can use to concatinate all classes per student into one column. Other databases wlll have other commands, you did not say where your data comes from

    – GuidoG
    Nov 20 '18 at 10:26


















0















There are 2 Objects with a relationship between them.
Student and Class.
Each student has one or more classes. I want to show student in a grid control (devexpress winform) and I prefer not to use master detail. I want to show classes in a single column, like : class A-class B (in a single row) or split the row like merging.










share|improve this question























  • You could do this in your sql statement also, sql server has the stuff statement you can use to concatinate all classes per student into one column. Other databases wlll have other commands, you did not say where your data comes from

    – GuidoG
    Nov 20 '18 at 10:26
















0












0








0








There are 2 Objects with a relationship between them.
Student and Class.
Each student has one or more classes. I want to show student in a grid control (devexpress winform) and I prefer not to use master detail. I want to show classes in a single column, like : class A-class B (in a single row) or split the row like merging.










share|improve this question














There are 2 Objects with a relationship between them.
Student and Class.
Each student has one or more classes. I want to show student in a grid control (devexpress winform) and I prefer not to use master detail. I want to show classes in a single column, like : class A-class B (in a single row) or split the row like merging.







c# winforms grid devexpress xpo






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 6:38









mtfmtf

138




138













  • You could do this in your sql statement also, sql server has the stuff statement you can use to concatinate all classes per student into one column. Other databases wlll have other commands, you did not say where your data comes from

    – GuidoG
    Nov 20 '18 at 10:26





















  • You could do this in your sql statement also, sql server has the stuff statement you can use to concatinate all classes per student into one column. Other databases wlll have other commands, you did not say where your data comes from

    – GuidoG
    Nov 20 '18 at 10:26



















You could do this in your sql statement also, sql server has the stuff statement you can use to concatinate all classes per student into one column. Other databases wlll have other commands, you did not say where your data comes from

– GuidoG
Nov 20 '18 at 10:26







You could do this in your sql statement also, sql server has the stuff statement you can use to concatinate all classes per student into one column. Other databases wlll have other commands, you did not say where your data comes from

– GuidoG
Nov 20 '18 at 10:26














2 Answers
2






active

oldest

votes


















0














It is possible to create an unbound column to populate it with your detail data. See the How to access a detail view's data within the CustomUnboundColumnData event handler example to learn how to do this.






share|improve this answer
























  • Can you write an example in c# for this purpose, please? - @svetlana

    – mtf
    Nov 20 '18 at 12:56













  • You can download the mentioned example by using the provided link above. Once you go to there, you will see the Download button. Alternatively, you can download this project directly from GitHub (github.com/DevExpress-Examples/…)

    – Svetlana
    Nov 20 '18 at 19:33



















0














From what database is this info coming ?

If you are using Sql Server you can merge the data in your query like this



declare @student table (studentid int, name varchar(20))
declare @class table (classid int, name varchar(20))
declare @studentclass table (studentid int, classid int)

insert into @student values (1, 'john'), (2, 'mary')
insert into @class values (1, 'english'), (2, 'mathematics')
insert into @studentclass values (1, 1), (1, 2), (2, 1)

select s.studentid,
s.name,
stuff(( replace (( select ' - ' + c.name
from @class c
inner join @studentclass sc on c.classid = sc.classid
where sc.studentid = s.studentid
order by c.name
For XML PATH ('')), '', '')
), 1, 3, '') as classes
from @student s


This will return this result :



studentid   name    classes 
--------- ---- -------
1 john english - mathematics
2 mary english


Other databases can do this also, the syntax will be different off course






share|improve this answer
























  • I'm using XPO objects and I don't use sql syntax in my code

    – mtf
    Nov 20 '18 at 11:38











  • Well no ORM tool will do this for you, thats why you have to do sql sometimes

    – GuidoG
    Nov 20 '18 at 12:38











  • what about linq in .net?

    – mtf
    Nov 20 '18 at 12:51













  • Maybe, I havent got this working in linq yet but im no expert in that

    – GuidoG
    Nov 20 '18 at 13:19











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387534%2fdisplay-relationship-in-a-devexpress-grid%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














It is possible to create an unbound column to populate it with your detail data. See the How to access a detail view's data within the CustomUnboundColumnData event handler example to learn how to do this.






share|improve this answer
























  • Can you write an example in c# for this purpose, please? - @svetlana

    – mtf
    Nov 20 '18 at 12:56













  • You can download the mentioned example by using the provided link above. Once you go to there, you will see the Download button. Alternatively, you can download this project directly from GitHub (github.com/DevExpress-Examples/…)

    – Svetlana
    Nov 20 '18 at 19:33
















0














It is possible to create an unbound column to populate it with your detail data. See the How to access a detail view's data within the CustomUnboundColumnData event handler example to learn how to do this.






share|improve this answer
























  • Can you write an example in c# for this purpose, please? - @svetlana

    – mtf
    Nov 20 '18 at 12:56













  • You can download the mentioned example by using the provided link above. Once you go to there, you will see the Download button. Alternatively, you can download this project directly from GitHub (github.com/DevExpress-Examples/…)

    – Svetlana
    Nov 20 '18 at 19:33














0












0








0







It is possible to create an unbound column to populate it with your detail data. See the How to access a detail view's data within the CustomUnboundColumnData event handler example to learn how to do this.






share|improve this answer













It is possible to create an unbound column to populate it with your detail data. See the How to access a detail view's data within the CustomUnboundColumnData event handler example to learn how to do this.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 6:51









SvetlanaSvetlana

33613




33613













  • Can you write an example in c# for this purpose, please? - @svetlana

    – mtf
    Nov 20 '18 at 12:56













  • You can download the mentioned example by using the provided link above. Once you go to there, you will see the Download button. Alternatively, you can download this project directly from GitHub (github.com/DevExpress-Examples/…)

    – Svetlana
    Nov 20 '18 at 19:33



















  • Can you write an example in c# for this purpose, please? - @svetlana

    – mtf
    Nov 20 '18 at 12:56













  • You can download the mentioned example by using the provided link above. Once you go to there, you will see the Download button. Alternatively, you can download this project directly from GitHub (github.com/DevExpress-Examples/…)

    – Svetlana
    Nov 20 '18 at 19:33

















Can you write an example in c# for this purpose, please? - @svetlana

– mtf
Nov 20 '18 at 12:56







Can you write an example in c# for this purpose, please? - @svetlana

– mtf
Nov 20 '18 at 12:56















You can download the mentioned example by using the provided link above. Once you go to there, you will see the Download button. Alternatively, you can download this project directly from GitHub (github.com/DevExpress-Examples/…)

– Svetlana
Nov 20 '18 at 19:33





You can download the mentioned example by using the provided link above. Once you go to there, you will see the Download button. Alternatively, you can download this project directly from GitHub (github.com/DevExpress-Examples/…)

– Svetlana
Nov 20 '18 at 19:33













0














From what database is this info coming ?

If you are using Sql Server you can merge the data in your query like this



declare @student table (studentid int, name varchar(20))
declare @class table (classid int, name varchar(20))
declare @studentclass table (studentid int, classid int)

insert into @student values (1, 'john'), (2, 'mary')
insert into @class values (1, 'english'), (2, 'mathematics')
insert into @studentclass values (1, 1), (1, 2), (2, 1)

select s.studentid,
s.name,
stuff(( replace (( select ' - ' + c.name
from @class c
inner join @studentclass sc on c.classid = sc.classid
where sc.studentid = s.studentid
order by c.name
For XML PATH ('')), '', '')
), 1, 3, '') as classes
from @student s


This will return this result :



studentid   name    classes 
--------- ---- -------
1 john english - mathematics
2 mary english


Other databases can do this also, the syntax will be different off course






share|improve this answer
























  • I'm using XPO objects and I don't use sql syntax in my code

    – mtf
    Nov 20 '18 at 11:38











  • Well no ORM tool will do this for you, thats why you have to do sql sometimes

    – GuidoG
    Nov 20 '18 at 12:38











  • what about linq in .net?

    – mtf
    Nov 20 '18 at 12:51













  • Maybe, I havent got this working in linq yet but im no expert in that

    – GuidoG
    Nov 20 '18 at 13:19
















0














From what database is this info coming ?

If you are using Sql Server you can merge the data in your query like this



declare @student table (studentid int, name varchar(20))
declare @class table (classid int, name varchar(20))
declare @studentclass table (studentid int, classid int)

insert into @student values (1, 'john'), (2, 'mary')
insert into @class values (1, 'english'), (2, 'mathematics')
insert into @studentclass values (1, 1), (1, 2), (2, 1)

select s.studentid,
s.name,
stuff(( replace (( select ' - ' + c.name
from @class c
inner join @studentclass sc on c.classid = sc.classid
where sc.studentid = s.studentid
order by c.name
For XML PATH ('')), '', '')
), 1, 3, '') as classes
from @student s


This will return this result :



studentid   name    classes 
--------- ---- -------
1 john english - mathematics
2 mary english


Other databases can do this also, the syntax will be different off course






share|improve this answer
























  • I'm using XPO objects and I don't use sql syntax in my code

    – mtf
    Nov 20 '18 at 11:38











  • Well no ORM tool will do this for you, thats why you have to do sql sometimes

    – GuidoG
    Nov 20 '18 at 12:38











  • what about linq in .net?

    – mtf
    Nov 20 '18 at 12:51













  • Maybe, I havent got this working in linq yet but im no expert in that

    – GuidoG
    Nov 20 '18 at 13:19














0












0








0







From what database is this info coming ?

If you are using Sql Server you can merge the data in your query like this



declare @student table (studentid int, name varchar(20))
declare @class table (classid int, name varchar(20))
declare @studentclass table (studentid int, classid int)

insert into @student values (1, 'john'), (2, 'mary')
insert into @class values (1, 'english'), (2, 'mathematics')
insert into @studentclass values (1, 1), (1, 2), (2, 1)

select s.studentid,
s.name,
stuff(( replace (( select ' - ' + c.name
from @class c
inner join @studentclass sc on c.classid = sc.classid
where sc.studentid = s.studentid
order by c.name
For XML PATH ('')), '', '')
), 1, 3, '') as classes
from @student s


This will return this result :



studentid   name    classes 
--------- ---- -------
1 john english - mathematics
2 mary english


Other databases can do this also, the syntax will be different off course






share|improve this answer













From what database is this info coming ?

If you are using Sql Server you can merge the data in your query like this



declare @student table (studentid int, name varchar(20))
declare @class table (classid int, name varchar(20))
declare @studentclass table (studentid int, classid int)

insert into @student values (1, 'john'), (2, 'mary')
insert into @class values (1, 'english'), (2, 'mathematics')
insert into @studentclass values (1, 1), (1, 2), (2, 1)

select s.studentid,
s.name,
stuff(( replace (( select ' - ' + c.name
from @class c
inner join @studentclass sc on c.classid = sc.classid
where sc.studentid = s.studentid
order by c.name
For XML PATH ('')), '', '')
), 1, 3, '') as classes
from @student s


This will return this result :



studentid   name    classes 
--------- ---- -------
1 john english - mathematics
2 mary english


Other databases can do this also, the syntax will be different off course







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 10:43









GuidoGGuidoG

5,28431744




5,28431744













  • I'm using XPO objects and I don't use sql syntax in my code

    – mtf
    Nov 20 '18 at 11:38











  • Well no ORM tool will do this for you, thats why you have to do sql sometimes

    – GuidoG
    Nov 20 '18 at 12:38











  • what about linq in .net?

    – mtf
    Nov 20 '18 at 12:51













  • Maybe, I havent got this working in linq yet but im no expert in that

    – GuidoG
    Nov 20 '18 at 13:19



















  • I'm using XPO objects and I don't use sql syntax in my code

    – mtf
    Nov 20 '18 at 11:38











  • Well no ORM tool will do this for you, thats why you have to do sql sometimes

    – GuidoG
    Nov 20 '18 at 12:38











  • what about linq in .net?

    – mtf
    Nov 20 '18 at 12:51













  • Maybe, I havent got this working in linq yet but im no expert in that

    – GuidoG
    Nov 20 '18 at 13:19

















I'm using XPO objects and I don't use sql syntax in my code

– mtf
Nov 20 '18 at 11:38





I'm using XPO objects and I don't use sql syntax in my code

– mtf
Nov 20 '18 at 11:38













Well no ORM tool will do this for you, thats why you have to do sql sometimes

– GuidoG
Nov 20 '18 at 12:38





Well no ORM tool will do this for you, thats why you have to do sql sometimes

– GuidoG
Nov 20 '18 at 12:38













what about linq in .net?

– mtf
Nov 20 '18 at 12:51







what about linq in .net?

– mtf
Nov 20 '18 at 12:51















Maybe, I havent got this working in linq yet but im no expert in that

– GuidoG
Nov 20 '18 at 13:19





Maybe, I havent got this working in linq yet but im no expert in that

– GuidoG
Nov 20 '18 at 13:19


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387534%2fdisplay-relationship-in-a-devexpress-grid%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

Npm cannot find a required file even through it is in the searched directory