iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Our custom grid has a custom check box in a Template type column. It's always the first column and always on the grid. It's strange as it does not render, even though the code is created, when the grid is first loaded. Once any post back is done via refresh grid data, sorting, grouping, etc. the check box is then rendered. It makes no sense and I'm not sure what I'm missing. Below are snippets that of our code:
public override bool OnPrepareDataBinding(object dataSource) { if (Page != null) { bool bFirstFormat = false; if (!Page.IsPostBack) { // retrieve the underlying structure this.RetrieveStructure(); // load, if any, the saved grid layout from // the database LoadGridPreferences(); // if it's not an InterSoft post back if (!this.IsFlyPostBack) { // and we have no layout loaded from the db if (!HaveUserLayout) { // then create our columns structure CreateColumnStructure(dataSource); // this flag tells us we're loading the grid with the // default formatting set from the database, i.e., the // user has not made any changes that were saved/loaded // from the db. bFirstFormat = true; } } } FormatGrid(dataSource, bFirstFormat); } return base.OnPrepareDataBinding(dataSource); }
The CreateColumnStructure does this to create the check box column:
... this.Columns.Clear(); // Add the row checker column... int iAddedAt = AddTemplateColumn(null); ... ClearCachedDataSource(); return;
public int AddTemplateColumn(string ColumnName) { ISNet.WebUI.WebGrid.WebGridColumn oCol = new ISNet.WebUI.WebGrid.WebGridColumn(ColumnName,ColumnName,ColumnName); oCol.ColumnType = ISNet.WebUI.WebGrid.ColumnType.Template; return this.Columns.Add(oCol); }
Once the columns are created, then we have a separate process that formats them. We read info about the default grid layout from the database and set it up based on the returned info. Whatever the case through, the check box columns always get created since this column is not bound. The code below gets hit regardless of whether the request is an update or not, so this is why I don't understand why it doesn't get rendered.
... // format the row checker column which is always the first one int iColIdx = 0; // remove and recreate the check box column // note that I'm only doing the RemoveAt/Insert because of this // rendering problem which I thought this may resolve, but it did not // normally I would not have these two lines this.Columns.RemoveAt(iColIdx); this.Columns.Insert(iColIdx,new ISNet.WebUI.WebGrid.WebGridColumn()); this.Columns[iColIdx].ColumnType = ISNet.WebUI.WebGrid.ColumnType.Template; this.Columns[iColIdx].EditType = ISNet.WebUI.WebGrid.EditType.NoEdit; this.Columns[iColIdx].IsRowChecker = false; this.Columns[iColIdx].ShowInSelectColumns = ISNet.WebUI.WebGrid.SelectColumns.No; this.Columns[iColIdx].Bound = false; PrismGridViewCheckBoxColumn cbc = new PrismGridViewCheckBoxColumn(); // set our custom properties cbc.HasClientCheckBoxOnClick = this.HasClientCheckBoxOnClick; cbc.ParentClientId = this.ID; cbc.ClientCheckBoxOnClick = this.ClientCheckBoxOnClick; ... this.Columns[iColIdx].CellTemplate = cbc; this.Columns[iColIdx].IsAutoWidth = false; this.Columns[iColIdx].Width = Unit.Pixel(20); this.Columns[iColIdx].CellStyle.Width = Unit.Pixel(20); this.Columns[iColIdx].CellStyle.HorizontalAlign = ISNet.WebUI.HorizontalAlign.Center; this.Columns[iColIdx].CellStyle.VerticalAlign = ISNet.WebUI.VerticalAlign.Middle;
The attached images show the intitial load of the grid with the default and saved db layouts as well as both after the Refresh grid data is hit. Notice the check boxes are not there in the initial load but there after the post back. Any help would be greatly appreciated. Thank you.
Please let me know if additional information is needed. We really need to get this fixed ASAP please.
Also, as a side note and one other issue related here is if we don't call "this.RetrieveStructure();" we get JavaScript errors all over the place on post backs after we load the layout from the database. These are internal errors to the WebGrid, e.g., "var vec863 =vad719.replace(/[&]/g,"%26");" and so on.
I've verified that the key field does get destroyed and that restoring it does work. So the basic solution is this:
// remember this since the call to RetrieveStructure() // destroys it. So does the call to LoadTablesStructureFromXml // in our LoadGridUserLayout custom method string strKeyField = this.KeyField; // retrieve the underlying structure this.RetrieveStructure(); // load, if any, the saved grid layout from // the database LoadGridUserLayout(); // now restore the key field this.RootTable.DataKeyField = strKeyField;
Note that the KeyField property is our custom property which returns this.RootTable.DataKeyField.
I believe I've found the problem. The call to RetrieveStructure() destroys the RootTable.DataKeyField property. I just have to set it back after calling RetrieveStructure().
Yousif,
Yes, calling RetrieveStructure will override all existing table structure and definition. I'm glad to hear that you figure out the solution.
Would you mind to set your own post as answer by clicking on "Mark as answer"? This will enable other users to recognize your thread as answered.
Thanks!
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname