Devexpress silverlight grid header checkbox column - asp.net

Is it possible to select or deselect the check box ( silverlight devexpress grid check box ) based on Grid header checkbox column , using client side events or server side events.
Sample Code :
<dxg:GridControl.View>
<dxg:TableView NavigationStyle="Cell" VerticalContentAlignment="Top" AllowColumnFiltering="True" AllowFilterEditor="True" ShowTotalSummary="True" Foreground="Black" ShowGroupPanel="False" AllowEditing="False" >
</dxg:TableView>
</dxg:GridControl.View>
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="EID" Fixed="Left" Width="70" VerticalAlignment="Top" AllowFocus="False" FilterPopupMode="CheckedList"></dxg:GridColumn>
<dxg:GridColumn FieldName="EN" Header="Name" Width="180" AutoFilterCondition="Contains" Fixed="Left" VerticalAlignment="Top" AllowFocus="False" FilterPopupMode="CheckedList" />
<dxg:GridColumn FieldName="DOJ" Header="Date Of Joining" Width="110" AllowFocus="False" FilterPopupMode="CheckedList" />
<dxg:GridColumn FieldName="CEX" Width="170" Visible="True" AutoFilterCondition="Like" AllowFocus="False" FilterPopupMode="CheckedList" />
<dxg:GridColumn FieldName="CheckBoxColumn" Width="170" Visible="True" AutoFilterCondition="Like" AllowFocus="False" FilterPopupMode="CheckedList" />
</dxg:GridControl.Columns>
<dxg:GridControl.GroupSummary>
<dxg:GridSummaryItem SummaryType="Count" />
</dxg:GridControl.GroupSummary>
<dxg:GridControl.TotalSummary>
<dxg:GridSummaryItem FieldName="EID" ShowInColumn="EN" SummaryType="Count"/>
</dxg:GridControl.TotalSummary>
</dxg:GridControl>

You have to modify the cell template in order to achieve what you want.
It will be something like this:
<dxg:GridColumn VisibleIndex="38" Header="h1" FieldName="h1" Name="h1">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<dxe:CheckEdit IsChecked="True" HorizontalAlignment="Center">
</dxe:CheckEdit>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
After creating the new template you can access your Column and load its content in order to modify the element within it:
var checkBox = MyGrid.Columns["h1"].CellTemplate.LoadContent() as DevExpress.Xpf.Editors.CheckEdit
Then
checkBox.IsChecked = true
Hope it helps!

Related

SAPUI5 OData binding to table

I try to bind campaign data from the OData service CUAN_CAMPAIGN_SRV to a TableSelectDialog element. In my view I have an Input field with input help:
<form:FormElement visible="true">
<form:label>
<Label text="Campaign" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit"/>
</form:label>
<form:fields>
<Input id="campaignId" type="Text" enabled="true" visible="true" width="auto" editable="true" showValueHelp="true" valueHelpOnly="true" valueHelpRequest="handleValueHelp"/>
</form:fields>
The value help calls the function handleValueHelp in my controller:
handleValueHelp: function(oController) {
this.inputId = oController.oSource.sId;
// create value help dialog
if (!this._valueHelpDialog) {
this._valueHelpDialog = sap.ui.xmlfragment(
"my.view.Campaigns",
this
);
this.getView().addDependent(this._valueHelpDialog);
}
// open value help dialog
this._valueHelpDialog.open();
}
This is when my table dialog (fragment) pops up:
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">
<TableSelectDialog id="campaignSelect" title="Select campaign" items="{path:'/CampaignSet'}" growingThreshold="5">
<columns>
<Column>
<Text text="Name"/>
</Column>
<Column>
<Text text="ID"/>
</Column>
<Column>
<Text text="Created at"/>
</Column>
<Column>
<Text text="Created by"/>
</Column>
</columns>
<items>
<ColumnListItem>
<Text text="{CampaignName}"/>
<Text text="{CampaignId}"/>
<Text text="{CreatedOn}"/>
<Text text="{CreatedBy}"/>
</ColumnListItem>
</items>
</TableSelectDialog>
So I tried to bind the EntitySet CampaignSet from OData Service CUAN_CAMPAIGN_SRV to the table. Therefore I added this code to my init() function of the controller:
var uname = "UNAME";
var pw = "PW";
var oModel = new sap.ui.model.odata.v2.ODataModel("https://host:port/sap/opu/odata/sap/CUAN_CAMPAIGN_SRV/",
true, uname, pw);
this.getView().setModel(oModel);
The problem is: the table contains no data and this error shows up in the console:
Translated from german: "In the context of Data Services an unknown internal server error occured"
iwfnd/error_log says this:
Invalid format (return table): Row Number 1, Property Name
'ChangedOn', Property Value '0 '
Why does ChangedOn even matter if I don't want to bind this property?
I can call something like below directly in browser with success:
https://host:port/sap/opu/odata/sap/CUAN_CAMPAIGN_SRV/CampaignSet('100001625')/CampaignName
What do I do wrong? Thank you for every hint!
ChangedOn is set to Nullable in the service definition:

Titanium Appcelerator Listview onItemLongclick alternative?

DATABINDING
How can I assign events like onItemclick to Listview items but instead of it behaving like onClick" I want something like "onLongClick" or "onSwipe", is there any workaround to this?
<ListView id="userList" defaultItemTemplate="user" onItemclick="deleteProfile">
<Templates>
<ItemTemplate bindId="user" name="user">
<Label bindId="name" class="name"/>
</ItemTemplate>
</Templates>
<ListSection id="section" dataCollection="users">
<ListItem template="user" user:id="{id}" user:adresse="{adresse}" name:text="{author}"/>
</ListSection>
</ListView>
ListView doesn't have Longpress event. You'll need to switch to TableView instead to get that to work.

DevExpress GridControl cell enabling/disabling

I have a grid control where some columns are editable, some are not.
I'd like to have more fine control, so that depending on some other fields of MyData, the corresponding cells will be enabled or not.
<dxg:GridControl ItemsSource="{Binding MyData}" AutoPopulateColumns="True">
<dxg:GridControl.Columns>
<dxg:GridColumn Header="Name" ReadOnly="True"/>
<dxg:GridColumn Header="ID 1" ReadOnly="False"/>
<dxg:GridColumn Header="ID 2" ReadOnly="False"/>
<dxg:GridColumn Header="ID 3" ReadOnly="False"/>
</dxg:GridControl.Columns>
</dxg:GridControl>
Can't find anything on the DevExpress support site yet. Would you please have any idea?
Thank you!
You can accomplish this task via handling the ShowingEditor event. You can set e.Cancel to True if a cell shouldn't be edited:
void TableView_ShowingEditor(object sender, DevExpress.Xpf.Grid.ShowingEditorEventArgs e)
{
if(...)
{
e.Cancel = true;
}
}
You can also accomplish this task via XAML style:
<Style TargetType="dxg:CellContentPresenter" BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=CellStyle}}">
<Setter Property="IsEnabled" Value="{Binding Path=RowData.Row.SomePropertyRelatedToEnabledState}"/>
</Style>

how to sort struts2jquerygrid column by default onload in client

I have used Struts2JqueryGrid and I did client side sorting by enable loadonce =true, but it will work while click the column header only. I want shot a column by default on pageload or gridload.
My code is
<sjg:grid id="grid_vehicleedit"
dataType="json"
href="%{remoteurl}"
loadonce="true"
gridModel="vchlst"
draggable="false"
hoverrows="false"
sortable="true"
viewrecords="true"
sortable="true"
>
<sjg:gridColumn name="vname" index="vname" sortable="true" title="Vehicle Name" key="true" />
<sjg:gridColumn name="imei" sorttype="int" sortable="true" title="Imei" index="imei" />
<sjg:gridColumn name="dtype" sortable="true" title="Splitter Type" width="80" index="dtype"/>
</sjg:grid>
Try adding these two attributes to your <sjg:grid> tag:
sortname="vname"
sortorder="asc"
And delete one of the occurrences of sortable="true". So you should end up with:
<sjg:grid id="grid_vehicleedit"
dataType="json"
href="%{remoteurl}"
loadonce="true"
gridModel="vchlst"
draggable="false"
hoverrows="false"
viewrecords="true"
sortable="true"
sortname="vname" // determines which column you want sorted on gridload
sortorder="asc" // default is ascending; use desc for descending
>
<sjg:gridColumn name="vname" index="vname" sortable="true" title="Vehicle Name" key="true" />
<sjg:gridColumn name="imei" index="imei" sorttype="int" sortable="true" title="Imei" />
<sjg:gridColumn name="dtype" index="dtype" sortable="true" title="Splitter Type" width="80" />
</sjg:grid>

Select parent row where expand subgrid in JQGrid

I have a JQGRid with two hierarchical level. I want to perform row selection when I expand a subgrid from the parent, because if I click on the plus icons, the row of the master grid is not selected.
I am trying to fire this code whene the sub grid is expanded, but it doers not work:
function showSubGrid(subgrid_id, row_id)
{
jQuery("#<%= jqGrid.ClientID %>").setSelection(row_id, true);
showSubGrid_jqGrid(subgrid_id, row_id);
}
This javascript function is fired whene the subgrid is expanded from the parent. Here is my server side code:
<trirand:JQGrid ID="jqMasterGrid" runat="server" Height="400px" AutoWidth="False" OnSorting="jqMasterGrid_OnSorting">
<Columns>
<trirand:JQGridColumn DataField="COD_VALUTAZIONE" Width="220" HeaderText = "Codice Valutazione" PrimaryKey="True" Sortable="True" />
<trirand:JQGridColumn DataField="InfAsp" Width="170" TextAlign="Center" Sortable="True"/>
<trirand:JQGridColumn DataField="LineaAsp" Width="170" TextAlign="Center" Sortable="True"/>
<trirand:JQGridColumn DataField="SuperAsp" Width="170" TextAlign="Center" Sortable="True"/>
<trirand:JQGridColumn DataField="Eccellente" Width="170" TextAlign="Center" Sortable="True"/>
</Columns>
<ToolBarSettings
ShowAddButton="false" ShowDeleteButton="false" ShowEditButton="false" ShowRefreshButton="false"
ShowSearchButton="false" ShowViewRowDetailsButton="false" ToolBarPosition="Hidden" ShowSearchToolBar="False" ShowInlineDeleteButton="False" ShowInlineEditButton="True" />
<HierarchySettings HierarchyMode="Parent" />
<ClientSideEvents SubGridRowExpanded="showSubGrid"/>
<ClientSideEvents LoadComplete="jqLoadComplete"></ClientSideEvents>
<PagerSettings PageSize="2000" />
</trirand:JQGrid>
Can you please help?
Use this in your parent jqgrid:
HierarchySettings HierarchyMode="Parent" SelectOnExpand="true"
By using this code when you will expand a row in parent jqgrid then the row in parent jqgrid will be selected.
Okay try something like this
subGridRowExpanded: function (subgrid_id, row_id) {
$("#grid").jqGrid('setSelection', "row_id");
}
I can not test my code right now, but if this doesn't work then let me know.

Resources