Skip to content

{ Tag Archives } UltraWebGrid

UltraWebGrid多表头的实现

首先在UltraWebGrid中设置好列,这里默认设置的列是col1,col2_1,col2_2,col3.其中col2_1和col2_2是要生成多表头的列。 在UltraWebGrid的InitializeLayout事件中写如下代码: ?View Code CSHARP // All the Headers for bound columns initialize to OriginX = 0. // Since we want them // to appear below the added column headers //we are going to need to move them down a level //先把所有列头都设为第二行 foreach (Infragistics.WebUI.UltraWebGrid.UltraGridColumn c in UltraWebGrid1.DisplayLayout.Bands[0].Columns) { c.Header.RowLayoutColumnInfo.OriginY = 1; //纵向起始点,0为第一行,1为第二行 } //创建一个列头对象 var [...]

Also tagged ,

UltraWebGrid的又一Bug?

UltraWebgrid增加一个模板列,在该模板列用<%#Eval() %>进行数据绑定,如下所示: <CellTemplate> <a onclick=”javascript:alert(<%#Eval(“name”)%>)”>链接的显示文字</a> </CellTemplate> UltraWebGrid首次数据绑定时,没任何问题,但是一旦网页PostBack的话,那么就会在该语句处报“未将对象引用设置到对象的实例”(Object reference not set to an instance of an object)。 而用GridView的话,则可以正常使用。 解决办法是用<a onclick=”alert(<%#DataBinder.Eval(Container.DataItem,”name”) %>)”>链接的显示文字</a>

Also tagged ,

如何获取点击模板列中控件所在的行号

在UltraWebGrid中,可以增加模板列。在该模板列中可以放入web控件。当在点时该web控件时,如何知道是点击了哪行上面的控件? 在web控件的点击事件中,可由以下方法得到该行的Index: ?View Code CSHARPvar rowIndex = ((CellItem)((Control)sender).NamingContainer).Cell.Row.Index;

Also tagged ,

在UltraWebGrid的InitializeRow事件中,操作模板列中的控件

首先在UltraWebGrid中,增加一个模板列(TemplatedColumn)。在该模板列的CellTemplated增加Checkbox服务端控件。 在InitializeRow事件中,可增加以下code,以操作每行的Checkbox ?View Code CSHARP var tc = (TemplatedColumn)e.Row.Cells[0].Column; var ci = (CellItem)tc.CellItems[e.Row.Index]; var cb = (CheckBox)ci.FindControl("cb"); cb.checked=true;

Also tagged ,

在UltraWebGrid中增加CheckBox列

首先,先在UltraWebGrid中增加一个模板列(Templated Column),该列的Type值要设置成”CheckBox”。那么,现在在UltraWebGrid中就已有了一个CheckBox列。 现在,要在该列的Header上加上一个CheckBox,当点击这个CheckBox时,可以在客户端上进行“全选”/“全不选”操作。 编辑这列的HeaderTemplate,增加一个id、name都为cbSelectAll的Checkbox。如下所示: <igtbl:TemplatedColumn Type=“CheckBox”> <HeaderTemplate> <input id=“cbSelectAll” name=“cbSelectAll” type=“checkbox” onclick=“SelectAll(0)”/> </HeaderTemplate> </igtbl:TemplatedColumn> 增加JavaScript函数SelectAll()和igrdInitializeLayout(): var oGrid; var cbSelectAll; //Selects all checkboxes in the grid function SelectAll(colIndex) { var checked = cbSelectAll.checked; for (i = 0; i < oGrid.Rows.length; i++) { oGrid.Rows.getRow(i).getCell(colIndex).setValue(checked); } } //Intialization function which sets the grid reference function igrdInitializeLayout(object) { oGrid [...]

Also tagged ,

在客户端阻止删除UltraWebGrid中的行

首先,要设置UltraWebGrid的DisplayLayout.ClientSideEvents.BeforeRowDeletedHandler = “BeforeDelete”。然后增加js函数BeforeDelete. function BeforeDelete(gridname, rowid) { //获取要删除的row var row=igtbl_getRowById(rowid); //获取当前行的第2个单元格 var value=row.getCell(1).getValue(); //检查该单元格的值,如果为真,则不删除该row。否则就删除该row if(value==true) { return true; } }

Also tagged ,

在客户端删除UltraWebGrid的所有行

有时需要在客户端上删除某个UltraWebGrid中所有的行,而如果按照帮助文件中例子的方法来操作的话,是无法删除行的。经询问NetAdvantage工程师,给出一个能用的例子。 ?View Code JAVASCRIPT//帮助中的例子,不可用 function DeleteRow() { // Row deletion needs to be allowed igtbl_getGridById("UltraWebGrid1").AllowDelete=1; // Get the first row in the grid var row=igtbl_getRowById("UltraWebGrid1r_0"); // Delete the first row in the grid igtbl_deleteRow("UltraWebGrid1","UltraWebGrid1r_0"); // Create a counter for the row id var cnt=0; // Create a loop, if the row has a next sibling [...]

Also tagged ,

WebCombo in UltraWebGrid

在将NetAdvantage升级到2008 vol2后,发现在2008 vol1版本中能正常使用的UltraWebGrid绑定WebCombo功能,如果WebCombo的Editable属性设为true话,那么在2008 vol2版本中将会抛出异常:WebCombo has the Editable property set to True; therefore it must have equal DataTextField and DataValueField to be used as an editor in an UltraWebGrid. 经与NetAdvantage开发人员联系,已确定在2008 vol2版本中,如果WebCombo的DataValueField不与DataTextField相同的话,那么在UltraWebGrid中的WebCombo不支持Editable=true。解决办法是用2008 vol1这个版本。 NetAdvantage开发人员回信如下: The webcombo does not support editable=true, when the DataValueField is different from the DataTextField.  This is done because the user only has the [...]

Also tagged , ,

UltraWebGrid的一个Bug

在使用NetAdvantage for .NET 2008 Vol.2 CLR3.5中的UltraWebGrid时,发现一个Bug. 如果按照Samples中Grid下的Row Updating例子写代码,那么当点击“Sumbit Change”时,会显示异常信息:System.NullReferenceException: 未将对象引用设置到对象的实例。 跟踪进去,在UpdateRowBatch事件中,并没报错,而却还没进”Sumbit Change”按钮的OnClick事件时,就已抛出异常了。 看了下代码,将databind()屏蔽,就不再抛同异常。

Also tagged ,