Hello,
I have a webhierarchicaldatagrid, User could enter his own (numeric) values on one column for the child level.
Each time the cell has been changed, I would like to put background colour in red if value is greater than 100, and make an asynchronous postback in order to run a sql update.
Using <ActivationClientEvents ActiveCellChanged="Handler"/> permits me to triggered an event client side each time I change a value data, but I didn't succeed to get the new value in this cell.
How could I get the new value in JS?
Secondly, How could I make a postback without lost the new data entered?
Thanks for your help
Best Regards
Damien
Hello Damien,
damienremusat said:Each time the cell has been changed, I would like to put background colour in red if value is greater than 100, and make an asynchronous postback in order to run a sql update.
The attached sample implements a similar scenario your can run it in your side and test. Please note that I've removed the ig_res folder from the website due to size upload limit.
Let me know if you have any questions.
Hello Rad,
Great Thanks for your help; it helps me in the bigger part.
But one problem remains: What I tried to do is storing a sql statement in an hidden field, then execute this code in server side:
function WebHierarchicalDataGrid1_CellEditing_ExitedEditMode(sender, eventArgs){
var cur_sample_size = document.getElementById('<%=CUR_SAMPLESIZE.ClientID%>').value;
var cur_phase = sender.get_parentRow().get_cell(0).get_value(); var cur_supsize = eventArgs.getCell().get_value();
var cur_point = eventArgs.getCell().get_row().get_cell(0).get_value();
var cur_descript = eventArgs.getCell().get_row().get_cell(1).get_value();
var cur_tol = eventArgs.getCell().get_row().get_cell(2).get_text();
var cur_size = eventArgs.getCell().get_row().get_cell(3).get_value();
var clause_where = "UPDATE %SCHEMA%.MEASSAMPLESIZES SET SUPVAL=" + cur_supsize + " WHERE MAINKEY='%MAINKEY%' " + "AND SAMPLESIZE='" + cur_sample_size + "' AND PHASE='" + cur_phase + "' " + "AND POINT='" + cur_point + "' AND DESCRIPT='" + cur_descript +"'";
document.getElementById('<%=HF_Commit_SupSize.ClientID%>' ).value = clause_where;
//red if out of tolerance
cur_tol = cur_tol.replace(',','.');
var diff = 0;
diff = parseFloat(cur_size) - parseFloat(cur_supsize);
eventArgs.getCell().get_element().style.backgroundColor =
__doPostBack("ctl00_ContentPlaceHolder1_StyleMain1_Module_MeasSampleSize_WebSplitter1_tmpl0_HF_Commit_SupSize", "");
}
And in server side, I run this statement:
protected void Commit_SupSize(){
string SQLQry = "";
SQLQry = HF_Commit_SupSize.Value.Trim();
SQLQry = SQLQry.Replace(
"%SCHEMA%", getProxy.GetBrandName());
"%MAINKEY%", this.GetStyleID);
getProxy.RunSQLCommand(SQLQry);
//GridSampleSize.Rows.Clear();
//this.LoadDS();
Just forgot to tell you that my WHDG is placed in an update panel.
When I exit my cell, I have an asynchronous postback, and this error:
InnerException:System.NullReferenceException: Object reference not set to an instance of an object. at Infragistics.Web.UI.GridControls.GridBot.LoadAdditionalClientState(Object state) at Infragistics.Web.UI.GridControls.ContainerGridBot.LoadAdditionalClientState(Object state) at Infragistics.Web.UI.Framework.RunBot.HandleRaisePostDataChangedEvent() at Infragistics.Web.UI.GridControls.GridBot.HandleRaisePostDataChangedEvent() at Infragistics.Web.UI.GridControls.ContainerGrid.RaisePostDataChangedEvent() at System.Web.UI.Page.RaiseChangedEvents() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Then, if I add these lines in server side code:
GridSampleSize.Rows.Clear();
this.LoadDS(); //Load the WHDG
I loose the row which was expanded before I exit the cell; in other word, the WHDG has all children row collapsed.
How could I keep my new values and keep my grid view?
Thanks again for your help
Regards
Hi Damien,
Since the child rows are supposed to be loaded you could try David's suggestion to iterate over the rows and determine theirs levels and based on that run your own logic :
>http://forums.infragistics.com/forums/p/36813/213171.aspx#213171
Hope this helps.
Hi Radoslav,
OK, but now, when the grid is displayed again (so after the postback), I loose my style: my cells are not anymore in red.
Is it possible to call the rowexpanded JS function for the current line expanded?
Else, another solution should be, in the grid init event, make again the cells in red, but I did not succeed to reach my "sub grid" cells to make this.
Any ideas?
Once time I will solve this, it should be operationnal. :-)
Thanks again and regards
if you keep this approach
damienremusat said: GridSampleSize.Rows.Clear(); this.LoadDS(); //Load the WHDG
You would be able to set which row to be initially expanded like this:
WebHierarchicalDataGrid1.DataBind();
WebHierarchicalDataGrid1.GridView.Rows[0].Expanded = true;
Make sure that you invoke DataBind before try to access a row or NullReferenceException will be thrown.