How to add cellClick or Rowclick in Devexpress Gantt? - devexpress

<dx:ASPxGantt ID="Gantt" runat="server" Height="700" Width="100%" >
<SettingsTaskList Width="40%">
<Columns>
<dx:GanttTextColumn FieldName="FleetNo" Caption="Fleet No" Width="100" />
</Columns>
</SettingsTaskList>
</dx:ASPxGantt>
Is there any option toadd cellClick or Rowclick in Devexpress Gantt?

Related

Display gridview cell values to textbox in asp.net

I'm working with asp.net nested gridview,in which I need to show the gridview cell values to the textbox for editing.
My problem is that I don't know how to display values to textbox if i ve used both template field & boundfield. Here is my aspx.
<Columns>
<asp:TemplateField ItemStyle-Width="10px">
<ItemTemplate>
<img alt = "" style="cursor: pointer" src="images/plus.png" />
<asp:Panel ID="pnsections" runat="server" Style="display: none;">
<asp:HiddenField ID="HdnId" runat="server" Value='<%# Eval("Dept_Name") %>' />
<asp:GridView ID="gvsections" Width="100%" CssClass="table table-bordered table-hover" runat="server" AutoGenerateColumns="false" OnRowDataBound="gvsections_rowdatabound" OnRowEditing="gvsections_rowediting" DataKeyNames="Dept_Name">
<Columns>
<asp:BoundField ItemStyle-Width="150px" DataField="currdept" HeaderText="Deptcurrent" />
<asp:BoundField ItemStyle-Width="150px" DataField="Dept_Name" HeaderText="SectionName" />
<asp:BoundField ItemStyle-Width="150px" DataField="FLDTYPE" HeaderText="Type" HeaderStyle-CssClass=" visible-lg visible-md" ItemStyle-CssClass=" visible-lg visible-md " />
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ItemStyle-Width="150px" DataField="Dept_Name" HeaderText="Department" />
<asp:BoundField ItemStyle-Width="150px" DataField="FLDTYPE" HeaderText="Type" />
</Columns>
</asp:GridView>
if you are writing the code in selectedindexchanging event of the grid view then try this and it will work
GridViewRow row = gvdepts.Rows[e.NewSelectedIndex];
deptname.Text=row.Cells[1].Text;
I hope this helps
In your code 3 fields contain dept name -- HdnId(Hiddenfield),inner gridview bound field (Dept_Name),Outer gridview bound field(Dept_Name).
1. deptname.Text = (gvdepts.SelectedRow.Cells[1].FindControl("HdnId") as HiddenField).Value;
2. deptname.Text = (gvdepts.SelectedRow.Cells[1].FindControl("gvsections") as GridView).Rows[0].Cells[2].Text;
3. deptname.Text = gvdepts.SelectedRow.Cells[2].Text;
may this link solve your problem:
http://www.aspforums.net/Threads/133072/Edit-Update-Delete-in-Nested-Child-GridView-in-ASPNet/

asp.net gridview index error

I have a gridview which was working fine.
It has some hidden columns, then visible columns.
When I clicked on each row, VB code behind gets values from each column value in the selected row and puts the value in separate textboxes underneath the gridview, eg
txtProjectId.Text = GridView1.SelectedRow.Cells(2).Text.ToString ' project ID
All worked fine.
Find below gridview code (made shorter) as per requested.
<div id="div_GRIDVIEW" class="div_Gridview" clientidmode="Static" runat="server" >
<asp:GridView ID="GridView1" Width="1370px" runat="server" AllowPaging="True" AllowSorting="True" OnSelectedIndexChanged = "OnSelectedIndexChanged" OnRowDataBound = "OnRowDataBound"
cssclass="STD_GridView L4" AutoGenerateColumns ="False" DataKeyNames="Id" DataSourceID="SqlDataSource2" PageSize = "5" GridLines="Horizontal" EnableViewState="False" >
<rowstyle cssclass="GridRowStyle HoverableRow" />
<alternatingrowstyle cssclass="GridAlternateRowStyle HoverableRow" />
<PagerStyle BackColor="#56b7e9" ForeColor="White" HorizontalAlign="Center" width="1370px" Height="20px"/>
<SelectedRowStyle BackColor="#eeeeee" />
<SortedAscendingHeaderStyle BackColor="#56b7e9" />
<SortedDescendingHeaderStyle BackColor="#56b7e9" />
<Columns>
<asp:CommandField ShowSelectButton="true" SelectImageUrl="~/images/xxstd/update16.gif">
<ItemStyle CssClass="hiddencol" /><HeaderStyle CssClass="hiddencol" />
</asp:CommandField>
<asp:BoundField DataField="Id" HeaderText="ProjectMainId"><ItemStyle CssClass="hiddencol" /><HeaderStyle CssClass="hiddencol" /> </asp:BoundField>
<asp:BoundField DataField="PDID" HeaderText="ProjectDetailsID"><ItemStyle CssClass="hiddencol" /><HeaderStyle CssClass="hiddencol" /> </asp:BoundField>
<asp:BoundField DataField="PN" HeaderText="PCFlag" ><ItemStyle CssClass="hiddencol" /><HeaderStyle CssClass="hiddencol" /> </asp:BoundField>
<asp:BoundField DataField="DD" HeaderText="OCFlag" ><ItemStyle CssClass="hiddencol" /><HeaderStyle CssClass="hiddencol" /> </asp:BoundField>
<asp:BoundField DataField="OFF" HeaderText="OFFlag" ><ItemStyle CssClass="hiddencol" /><HeaderStyle CssClass="hiddencol" /> </asp:BoundField>
<asp:BoundField DataField="DCF" HeaderText="DCFlag" ><ItemStyle CssClass="hiddencol" /><HeaderStyle CssClass="hiddencol" /> </asp:BoundField>
<asp:BoundField DataField="OnCF" HeaderText="OnCFlag" ><ItemStyle CssClass="hiddencol" /><HeaderStyle CssClass="hiddencol" /> </asp:BoundField>
<asp:BoundField DataField="RF" HeaderText="ReadyFlag" ><ItemStyle CssClass="hiddencol" /><HeaderStyle CssClass="hiddencol" /> </asp:BoundField>
<asp:BoundField DataField="DF" HeaderText="DeclineFlag" ><ItemStyle CssClass="hiddencol" /><HeaderStyle CssClass="hiddencol" /> </asp:BoundField>
....many more hidden columns here (over 50)...
<asp:TemplateField SortExpression="PDID" >
<HeaderTemplate>
<asp:LinkButton ID="lbItem" runat="server" Text="Project#" CommandName="Sort" CommandArgument="Item" tabindex="1000"></asp:LinkButton><br />
<asp:TextBox runat="server" ID="txtS_PDID" CssClass="HF" OnTextChanged="txtItem_TextChanged"></asp:TextBox>
</HeaderTemplate>
<ItemTemplate>
<table >
<tr >
<td class="STD_normal" style="width:50px;font-weight:bold"><%#Eval("PDID")%></a></td>
</tr>
<tr>
<td class="STD_Normal_Grey" style="width:50px;"><%#Eval("Id")%> </td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField SortExpression="Item">
<HeaderTemplate>
<asp:LinkButton ID="lbItem" runat="server" Text="Project Name" CommandName="Sort" CommandArgument="Item" tabindex="1000"></asp:LinkButton><br />
<asp:TextBox runat="server" ID="txtS_PDID" CssClass="HF" OnTextChanged="txtItem_TextChanged"></asp:TextBox>
</HeaderTemplate>
<ItemTemplate>
<table >
<tr>
<td class="STD_normal" style="width:150px; font-weight:bold"><%#Eval("PN")%>
</td>
</tr>
<tr>
<td class="STD_Normal_Grey" style="width:150px"><%#Eval("DD", "{0:dd-MMM-yyyy}")%> </td>
</tr>
</table>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
And here is part of the code when row is selected....the index error occurs on Session("txtcurrentID") = GridView1.SelectedRow.Cells(1).Text.ToString :
Protected Sub OnSelectedIndexChanged(sender As Object, e As EventArgs) 'Handles gridview1.SelectedIndexChanged
Session("txtcurrentID") = GridView1.SelectedRow.Cells(1).Text.ToString
Session("txtcurrentPDID") = gridView1.SelectedRow.Cells(2).Text.ToString
Session("PCF") = GridView1.SelectedRow.Cells(3).Text.ToString
Session("OCF") = GridView1.SelectedRow.Cells(4).Text.ToString
Session("OFF") = GridView1.SelectedRow.Cells(5).Text.ToString
Session("DCF") = GridView1.SelectedRow.Cells(6).Text.ToString
Session("OnCF") = GridView1.SelectedRow.Cells(7).Text.ToString
end sub
So now when I click on each row, I get the following error:
Index was out of range. Must be non-negative and less than the size of the collection.
Everything works fine, the gridview displays correctly and the header filters look fantastic.
However I cannot longer click/select each row...
Any ideas ??

Grid display changes on re binding the grid

I have a grid on my aspx page.I have set its font property to small..
On page load it is all okay..
but once I perform some action like a delete activity given in the grid itself..and the grid is bound again by recalling the method to bind grid..
the grid seems to be bigger with big fonts.
What could be the trouble?
<asp:GridView ID="grdSMEList" runat="server" Width="100%" BorderWidth="1px" BorderStyle="Solid"
Font-Size="Small" AutoGenerateColumns="False" BorderColor="#ffcc00" RowStyle-BorderColor="#ffcc00"
AllowPaging="true" PageSize="10" OnPageIndexChanging="GrdDynamic_PageIndexChanging"
DataKeyNames="Resource Personnel No" OnRowCommand="GrdDynamic_RowCommand" RowStyle-BorderStyle="Solid"
RowStyle-BorderWidth="1px" GridLines="Both" Height="104px">
<PagerSettings NextPageText="&gt;&gt" PageButtonCount="5" PreviousPageText="&lt;&lt"
FirstPageText="" LastPageText="" Mode="Numeric" />
<PagerStyle HorizontalAlign="Right" Font-Size="Medium" />
<Columns>
<asp:BoundField DataField="Resource Personnel No" HeaderText="Resource Personnel No" ItemStyle-Width="100px" />
<asp:BoundField DataField="RES Name" HeaderText="ResourceName" ItemStyle-Width="100px" />
<asp:TemplateField HeaderText="Deactivate" >
<ItemTemplate>
<div style="text-align:center;">
<asp:LinkButton ID="linkDeactivate" CommandName="cmdDeactivate" OnRowCommand="GrdDynamic_RowCommand"
CommandArgument='<%# Eval("Resource Personnel No") %>' OnClientClick="return confirm('Are you sure you want to Deactivate?');"
runat="server">Deactivate</asp:LinkButton>
</div>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="2%" />
</asp:TemplateField>
</Columns>
</asp:GridView>
Did you try specifying the font color in ItemTemplate ? Its worth a try.

How to pass the boundfield value to a label in the same page?

In my aspx page, I have a detailsView and a label. The label's text should show the same value as a boundfield of the detailsview. How do I get both of them populated at the same time?
Following is my apsx page, I tried the Eval, it didn't work. I don't want to do it in the code-behind.
<tr>
<td > <asp:label runat="server" text='<%# Eval("ReporterName")%>'/></td>
</tr>
<tr>
<td>
<asp:DetailsView ID="DetailsView1" runat="server" >
<Fields>
<asp:BoundField DataField="sprID" HeaderText="SPRID" ReadOnly="True"
SortExpression="sprID" >
<HeaderStyle Width="230px" />
</asp:BoundField>
<asp:BoundField DataField="ProductName" HeaderText="Product"
SortExpression="ProductName" />
<asp:BoundField DataField="DivisionName" HeaderText="Technology Group"
SortExpression="DivisionName" />
<asp:BoundField DataField="DisciplineName" HeaderText="Discipline"
SortExpression="DisciplineName" />
<asp:BoundField DataField="ReporterName" HeaderText="Reporter"
SortExpression="ReporterName" />
<asp:BoundField DataField="OwnerName" HeaderText="Owner"
SortExpression="OwnerName" />
<asp:BoundField DataField="SalesLeadName" HeaderText="SalesLead"
SortExpression="SalesLeadName" />
<asp:BoundField DataField="RegionName" HeaderText="Region"
SortExpression="RegionName" />
</Fields>
Try using the DataBound event, like this:
protected void DetailsView1_DataBound(object sender, EventArgs e)
{
Label1.Text = DataBinder.Eval(DetailsView1.DataItem, "SomeValue").ToString();
}

RadGrid RadComboBox Client Popup Help

Need some help figuring this one please. I would like to add an On RowClick Event handler to my RadGrid to handle the selections from RadComboBox in the RadGrid Editform mode. What I would like to do is to, when user makes a selection from the combobox, display a RadWindow to allow user make additional Selections to be displayed in a textbox in the RadGrid Editform. SO far, what I have displays nothing, not even alertboxes
function RowCreated(rowObject) {
alert("Row with Index: " + rowObject.Index + " was created");
}
function RowSelected(sender, args) {
alert("row selected");
inputFieldValue = args.getDataKeyValue("Type");
alert(inputFieldValue);
}
function RowClick(rowIndex, e) {
alert("row Clicked");
var sourceElement;
alert(rowIndex);
}
The attachment to the grid happens in the client events tag
<telerik:RadGrid ID="securityGrid" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="false" Height="99.9%" AllowCustomPaging="true">
<MasterTableView ShowFooter="true" AutoGenerateColumns="False" AllowSorting="true" AllowPaging="true" EnableViewState="true" ClientDataKeyNames="HKey" DataKeyNames="HKey">
<NoRecordsTemplate>
<div align="center" style="font-weight: bold; font-size: 16px; color: Green; width: 100%;">
There Are No Records To Display. Please Select Another View.</div>
</NoRecordsTemplate>
<Columns>
<telerik:GridBoundColumn UniqueName="EHKey" Visible="false" DataField="EHKey" />
<telerik:GridCheckBoxColumn UniqueName="Active" HeaderText="Active" DataField="Active"
ColumnEditorID="ReportEditor">
<ItemStyle Width="70" />
<HeaderStyle Width="70" />
</telerik:GridCheckBoxColumn>
<telerik:GridDropDownColumn UniqueName="UILocation" DataSourceID="UILocation_DS"
HeaderText="UI Location" DataField="UILocation" ListTextField="Description" ListValueField="PrimaryKey"
DropDownControlType="RadComboBox" ColumnEditorID="ReportEditor">
<ItemStyle Width="20%" Height="18" />
<HeaderStyle Width="20%" />
</telerik:GridDropDownColumn>
<telerik:GridDropDownColumn UniqueName="Type" DataSourceID="SecurityType_DS" HeaderText="Type"
DataField="SecurityType" ListTextField="Description" ListValueField="PrimaryKey"
DropDownControlType="RadComboBox" ColumnEditorID="ReportEditor">
<ItemStyle Width="120" Height="18" />
<HeaderStyle Width="120" />
</telerik:GridDropDownColumn>
<telerik:GridBoundColumn UniqueName="Item" HeaderText="Item" DataField="ItemList"
ColumnEditorID="ReportEditor">
<ItemStyle Width="10%" />
<HeaderStyle Width="10%" />
</telerik:GridBoundColumn>
<telerik:GridDropDownColumn UniqueName="Access" DataSourceID="AccessType_DS" HeaderText="Access"
DataField="AccessType" ListTextField="Description" ListValueField="PrimaryKey"
DropDownControlType="RadComboBox" ColumnEditorID="ReportEditor">
<ItemStyle Width="120" />
<HeaderStyle Width="120" />
</telerik:GridDropDownColumn>
<%-- <telerik:GridBoundColumn UniqueName="ItemList" Visible="false" DataField="ItemList" />--%>
<telerik:GridEditCommandColumn HeaderText="Edit" ButtonType="ImageButton" UniqueName="EditCommandColumn">
<ItemStyle Width="40" CssClass="WATSImageButton" />
<HeaderStyle Width="40" />
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn UniqueName="DeleteCommandColumn" ButtonType="ImageButton"
CommandName="Delete" HeaderText="Del" ConfirmTitle="Delete Strategy Milestone!"
ConfirmText="Are you sure you want to delete this record?" ConfirmDialogType="RadWindow"
ConfirmDialogHeight="100" ConfirmDialogWidth="350">
<ItemStyle Width="35" CssClass="WATSImageButton" />
<HeaderStyle Width="35" />
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings>
<FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="0" Width="100%"
CssClass="masterTable" />
<FormTableStyle CellSpacing="0" CellPadding="0" Width="50%" />
<FormStyle Width="100%" BackColor="#ffffe1"></FormStyle>
<EditColumn ButtonType="ImageButton" CancelText="Cancel" UpdateText="Update" InsertText="Add" />
</EditFormSettings>
</MasterTableView>
<ClientSettings>
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
<ClientEvents OnRowClick="RowClick" OnGridCreated="GridCreated" />
<Selecting AllowRowSelect="false" />
<ClientEvents />
</ClientSettings>
</telerik:RadGrid>
Debug your js code to see what part of it gets processed and whether errors occur. This can help you trace what's wrong.
Look at the following line:
alert("Click on row instance: " + eventArgs.get_itemIndexHierarchical());
You haven't defined eventArgs. This is the first line of the function so it makes sense that "nothing" happens when you click on the row.
Change your function to be as follows:
function RowClick(rowIndex, eventArgs) {
alert("Click on row instance: " + eventArgs.get_itemIndexHierarchical());
var e = window.event;
var sourceElement;
alert(sourceElement);
if (e.srcElement) {
sourceElement = e.srcElement;
alert("sourceElement");
}
else if (e.target) {
sourceElement = e.target;
alert("target");
}
alert("About to check ROw Index");
if (rowIndex != null) {
alert("Checked ROw Index");
inputField = grid.MasterTableView.Rows[rowIndex].Control.getElementsByTagName("INPUT")[0];
alert(inputField);
selvalue = sourceElement.value;
alert(selvalue);
if (inputField != null) {
alert("About to show it");
var popuppage = "userroleselect.aspx" + "?sel=" + selvalue + "&avail=" + inputField.value;
alert("Shown it!");
window.radopen(popuppage, "UserRoleDialog");
}
else {
alert("Did Not Make it");
}
}
}
Notice the eventArgs parameter also notice the the variable e is now defined in the function.

Resources