Hi All,
I am using infragistic 2013 in my application when i am trying to do sorting i am unable to do it.
Grid type i am using.
<ig:WebDataGrid ID="wdGrid_PSTS" runat="server" Height="500px" Width="99%" AutoGenerateColumns="false" EnableDataViewState ="true" >
<ig:BoundDataField DataFieldName="Id" Key="Id" Width="50px"> <Header Text="Id"></Header> </ig:BoundDataField>
<ig:BoundDataField DataFieldName="PSTStatus" Key="PSTStatus" Width="125px"> <Header Text="PSTStatus"></Header> </ig:BoundDataField>
<Behaviors> <ig:Sorting SortingMode="Multi" Enabled="true"> </ig:Sorting> <ig:ColumnResizing Enabled="true"></ig:ColumnResizing> <ig:Selection CellClickAction="Row" RowSelectType="Multiple"></ig:Selection> </Behaviors>
It functionality is not working. Kindly suggest.Its been 2 days and i am still stuck .I am experiencing Infrgistic first time.
Hello Dheeraj,
Thank you for the code-snippet you have provided.
I tested the WebDataGrid's sorting functionality by using the one you have provided and I was unable to reproduce the behavior you have described.
I have attached a sample application that demonstrates the approach from above. Would you please modify it, so the issue is reproduced and send it back to me? Having this information will help me further investigate this matter for you.(Please note that you might have to change the assembly references and the stylesSetPath property in the Web.config so they target your specific version and path for the styles.)
If you have any questions, please let me know.
0410.WebDataGrid_sample.zip
Hi Tacho,
Thanks for your prompt respond.
I have 1 drop down when i select the value from that drop down and click on search button grid is populated.
now i have done some code changes in design side.
function sort() { debugger; var grid = $find("wdGrid_PSTS"); // Sort column by calling sortColumn method and passing in the column and the sort direction // Sort direction is 0, 1, or 2 for none, ascending, or descending. grid.get_behaviors().get_sorting().sortColumn(grid.get_columns().get_columnFromKey("Id"), 1, false); grid.get_behaviors().get_sorting().sortColumn(grid.get_columns().get_columnFromKey("PSTName"), 1, false); grid.get_behaviors().get_sorting().sortColumn(grid.get_columns().get_columnFromKey("UserName"), 1, false); }
Now value is sorting but new issue had occurred which is that when i select other value from the dropdown grid is not getting clear and irrespective any value selecting from drop down same value is pertain until i refresh the page .
Please suggest.
We are glad you managed to resolve the initial issue. For this second one, please, share with us the code you execute in code-behind on changing the selection in the drop-down, so we can investigate what happens.
Looking forward to hearing from you.
Hi Galina,
Thanks for your Prompt respond. Please find Code snippet below
1st dropdown
protected void wddInvestigations_SelectionChanged(object sender, Infragistics.Web.UI.ListControls.DropDownSelectionChangedEventArgs e) { wdGrid_PSTS.DataSource = null; wdGrid_PSTS.Rows.Clear(); // this.wdGrid_PSTS.Behaviors.Sorting.SortedColumns.Clear(); hfInvNo.Value = this.wddInvestigations.SelectedValue; BindAssignData(Convert.ToInt32(hfInvNo.Value)); btnSearch.Enabled = true;
}
2nd dropdown
protected void wddAssign_SelectionChanged(object sender, Infragistics.Web.UI.ListControls.DropDownSelectionChangedEventArgs e) { wdGrid_PSTS.DataSource = null; wdGrid_PSTS.Rows.Clear(); wdGrid_PSTS.DataBind(); btnSearch.Enabled = true; }
protected void wdGrid_PSTS_ColumnSorted(object sender, SortingEventArgs e) {
if (wddInvestigations.SelectedItemIndex == 0) { wdGrid_PSTS.DataSource = null; wdGrid_PSTS.Rows.Clear();
else { BindPSTs();
private void BindPSTs() { try { // int inv = Convert.ToInt32(wddInvestigations.SelectedValue); DataTable dt = GetPSTs(); DataSet dsPST = new DataSet();
dsPST.Tables.Add(dt); if (dt.Rows.Count > 0) { this.wdGrid_PSTS.DataSource = dsPST; this.wdGrid_PSTS.DataBind(); // this.wdGrid_PSTS.Behaviors.Sorting.SortedColumns.Add(this.wdGrid_PSTS.Columns["Id"], Infragistics.Web.UI.SortDirection.Descending); //this.wdGrid_PSTS.Behaviors.Sorting.SortedColumns.Clear(); } else { // Jaleel //this.wdGrid_PSTS.Clear(); // Jaleel //this.wdGrid_PSTS.Columns.Clear(); //jaleel
// Dheeraj 13-05-2019 wdGrid_PSTS.DataSource = null; wdGrid_PSTS.Rows.Clear();
// END }
} catch(Exception ex) { this.lblErrorMsg.Text = ex.Message; this.lblErrorMsg.ForeColor = System.Drawing.Color.Green;
private DataTable GetPSTs() {
DataTable dt = new DataTable(); dt.Columns.Add("Id"); dt.Columns.Add("UserName"); dt.Columns.Add("MsgType"); dt.Columns.Add("PSTStatus"); dt.Columns.Add("StartDate", Type.GetType("System.DateTime")); dt.Columns.Add("EndDate", Type.GetType("System.DateTime")); dt.Columns.Add("PSTName"); dt.Columns.Add("Location"); dt.Columns.Add("PSTSize");
if (m_LookupMgr == null) m_LookupMgr = new LookupManager();
// Check to see the asssignId. It may be null because of confidentiality
List<PSTDTO> pstDTOList = new List<PSTDTO>(); InvestigationManager invMgr = new InvestigationManager(); if (wddAssign.SelectedValue == "0") { //int inv = Convert.ToInt32(this.wddInvestigationNo.SelectedRow.Cells[0].Text); // Jaleel - Start //int inv = Convert.ToInt32(wddInvestigationNo.CurrentValue); //int inv = Convert.ToInt32(ddlInvestigation.SelectedValue); // int inv = Convert.ToInt32(wddInvestigations.SelectedValue);
int inv = Convert.ToInt32(wddInvestigations.SelectedValue); // Jaleel - End
List<InvAssignmentDTO> assigns = invMgr.GetAllInvAssignmentsByInvId(inv); foreach (InvAssignmentDTO dto in assigns) { pstDTOList.AddRange(GetAssignPSTS(dto.Id)); } } else { int assignId = Convert.ToInt32(wddAssign.SelectedValue); pstDTOList.AddRange(GetAssignPSTS(assignId)); }
// Created PST status int pstStatusCreatedId = SiteHelper.GetGlobalLookupByCodeLookup(Utils.ConstantHelper.PST_STATUS.PST_STATUS_CREATED.ToString()).Id; int pstStatusInvalId = SiteHelper.GetGlobalLookupByCodeLookup(Utils.ConstantHelper.PST_STATUS.PST_STATUS_BURNED_INVALID.ToString()).Id;
foreach (PSTDTO dto in pstDTOList) { if ((dto.StatusId == pstStatusCreatedId) || (dto.StatusId == pstStatusInvalId)) { DataRow dr = dt.NewRow(); dr["Id"] = dto.Id; dr["UserName"] = GetUserName(dto.InvUserId); dr["MsgType"] = m_LookupMgr.GetEDiscoveryMsgTypeById(dto.MessageTypeId).MsgSubType; dr["PSTStatus"] = SiteHelper.GetGlobalLookupById(dto.StatusId).Name; dr["StartDate"] = SiteHelper.GetDatetoString(dto.StartDate); dr["EndDate"] = SiteHelper.GetDatetoString(dto.EndDate); dr["PSTName"] = dto.PSTName; dr["Location"] = dto.PSTLocation; dr["PSTSize"] = dto.PSTSIze; dt.Rows.Add(dr); } } return dt; }
Please try to respond ASAP since i m stuck in this issue for 2 days. I think its a very subtle issue but unable to identify
Hello,
Thank you for the code snippets. There's nothing obvious in the code that seems not OK. Please, make sure you are not rebinding the drop-downs on every page postback. I am attaching a small sample application I used to test rebinding the grid on changing the selection in a drop-down. Review it and let us know if you need further assistance on the matter.
6661.WebDataGrid_sample.zip