DataTable sorting column on click

DataTable sorting column on click

ak11ak11 Posts: 14Questions: 6Answers: 0

Hello,

I have data coming from DataTable as

            var aaData = GetData().AsEnumerable().Select(x => new {
                Id = x["myId"],
                Desc = x["Desc"]                 
            });

How do I set sorting when user clicks on sorting buttons on columns?

Thanks,

Answers

  • ak11ak11 Posts: 14Questions: 6Answers: 0
    edited December 2019

    not sure why the code isn't appearing properly in the initial post, so here it is again

        return Execute(() => {
                        string Id = request.Id;
                        var Data = someapi.GetData(Id).AsEnumerable().
                                              Select(x => new {
                            Id = x["myID"],
                            Desc = x["Desc"],
    
                        });
    
                        int totalCount = Data.Count();
    
                    //How to sort here given I have the above..
    
                    });
    
  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Sorting happens by default, or do you mean some form of custom sort?

    Colin

This discussion has been closed.