Ext.net 2.0 ComboBox, tiny bug - ext.net

I have a very tricky issue which bothered me really long..
I was trying to use Ext.net 2.0 combobox to display options from remote DB. Everything works fine, but there is only one issue, when the page first loaded, if I do not change a selection of the combo, in c#, the combobox.value equals to the text instead of id.
Database is very easy: 'Test_table' has two columns, one called Tid, the other is TextContent.
My frontend code:
<ext:ComboBox ID="TestCombo" runat="server" Editable="false" DisplayField="TextContent"
ValueField="Tid" TypeAhead="true" AllowBlank="false" EmptyText="Select a text
id..." SelectOnFocus="true" FieldLabel="test text">
<Store>
<ext:Store ID="TestStore" runat="server" AutoLoad="true" AutoDataBind="true"
OnReadData="testStore_RefreshData">
<Proxy>
<ext:PageProxy>
</ext:PageProxy>
</Proxy>
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="Tid">
<Fields>
<ext:ModelField Name="Tid" />
<ext:ModelField Name="TextContent" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:ComboBox>
After click a save button, I try to add breakpoint to get var _M = TestCombo.value However, it appears that if I click save after I changed the selection of the combobox, _M's value will be correct(equals to Tid value), otherwise, _M's value will be the TextContent..
Anyone has idea what caused this issue? Or does anyone have some good samples for Ext.net 2.0+ combobox code (read from remote db)?

Related

Decimals translated by browser when a dropdown is used

The dot is removed by the browser and results in a value of 25 if you choose 0.25 (hence the error below).
The example config with listitems results in a dropdown in TFS. This works fine in Firefox. Chrome and Internet Explorer remove the dot and e.g. transform the value 0.5 to 5
<FIELD name="Effort" refname="Microsoft.VSTS.Scheduling.Effort" type="Double" reportable="measure" formula="sum">
<HELPTEXT>The estimated effort to implemented the backlog item</HELPTEXT>
<ALLOWEDVALUES expanditems="true">
<LISTITEM value="0" />
<LISTITEM value="0.25" />
<LISTITEM value="0.5" />
<LISTITEM value="1" />
<LISTITEM value="2" />
<LISTITEM value="3" />
<LISTITEM value="5" />
</ALLOWEDVALUES>
</FIELD>
It can be solved for Internet Explorer by putting English as language preference, but that is not a solution since most of our users have set Dutch. Setting the dot as a decimal separator isn't a solution either, because Dutch uses a comma for that.
How can I solve this without bothering the end user?
You need to define a control field .Please follow this tutorial it will surely help you.
Click here Control field numberFormat
or you can also try my sample
<Control Type="FieldControl" FieldName="Microsoft.VSTS.Scheduling.Effort" Label="Rough Estimation:" LabelPosition="Left" NumberFormat="DecimalNumbers" />
Feel free to ask if it not work .Thanks
Someone from Microsoft found the issue and they are solving it;
"FYI, we found this to be an issue with localization. We are fixing it 😊"

How to use CausesValidation on an ext.net button?

This question is about ext.net.
I hope to perform a form validation when the save button is clicked. In a regular ASP.NET webform, we usually use CausesValidation="true" ValidationGroup="gpSubmit" on the save button. But in an ext.net button, those two properties seems to be ineffective.
Any advice? How do you focus on the DOM control that fails the validation?
Here is my code.
<ext:Button ID="btnSave" runat="server" Text="Save" Icon="ApplicationEdit"
CausesValidation="true" ValidationGroup="gpSubmit">
<DirectEvents>
<Click
OnEvent="btnSave_Click"
Before="...;"
Success="...;"
Failure="...;">
<EventMask ShowMask="true" Msg="Processing" />
</Click>
</DirectEvents>
</ext:Button>

How to make ext.net RadioGroup a required field?

We are using ext.net. I know how to make a textbox a required field, but am having trouble to force our user to make a selection on the radio group or a check box group. I know someone just assign a default value to one of the radio button, but our customer wants to leave them unchecked in the beginning but forces the web users to make a choice, which is understandable.
It appears IndicatorText and AllowBlank properties are not effective even though they are listed in the IntelliSense.
<ext:RadioGroup ID="rdGrpGender" runat="server"
ItemCls="x-check-group-base" FieldLabel="Gender"
ColumnsWidths="60,60"
IndicatorText="*" IndicatorCls="cssIndicator" AllowBlank="false">
<Items>
<ext:Radio ID="rdoMale" runat="server" BoxLabel="M" />
<ext:Radio ID="rdoFemale" runat="server" BoxLabel="F" />
</Items>
</ext:RadioGroup>
Can any expert help me out? Thanks a lot.
you can validate it like this
<ext:Button ID="Button1" runat="server" Text="Validate"><Listeners><Click Handler="#{rdGrpGender}.validate();" /></Listeners></ext:Button>

Doing the Drag and Drop from one Grid to Another Grid made Form elements Irregular

Hi, I am Implementing the Drag Drop functionality using the Link
http://examples.ext.net/#/DragDrop/Grid/Grid_to_Grid/
and i have implemented this on my form as when i click on One Grid
Column setting Icon that gridpanel should be hide and this
panel(ID:pnlGridDragDrop) which are containing two DragDrop grids
should be visible.
after Displaying the pnlGridDragDrop when i trying to Drag items from
first Grid to another the above Tab Design becomes disappear.
What is the Reason here.
Please find the Image i have attached and the Code in my Program is as
like below.
<ext:GridPanel ID="grdProjectsView" Width="705" Title="Projects" >
---
columns
------
<ext:ImageCommandColumn ID="imgSettings" runat="server" Text="Settings" Resizable="false">
<Commands>
<ext:ImageCommand Icon="BasketEdit" Style="text-align: center" CommandName="Settings">
</ext:ImageCommand>
</Commands>
<Listeners>
<Command Handler="#{DirectMethods}.fnDisplaySettings(record.data.ProjectID,record.data.ProjectName);" />
</Listeners>
</ext:ImageCommandColumn>
---
---
</ColumnModel>
</ext:GridPanel>
// Drag Drop Grids Panel
<ext:Panel ID="pnlProjMemberGrid" runat="server" Border="false">
<LayoutConfig>
<ext:HBoxLayoutConfig Align="Stretch" Padding="5" />
</LayoutConfig>
<Items>
<ext:GridPanel ID="grdNonProjectEmloyeeList">
</ext:GridPanel>
<ext:GridPanel ID="grdProjectEmloyeeList">
</ext:GridPanel>
Thank you.
Need to adjust the Heights of the panels/Container

Exporting Gridview to Excel in web app

Hopefully you guys can help me out. I tried a lot of different things and cant get this working.
I have a gridview as below in a update panel:
<asp:UpdatePanel ID="udpReport" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:GridView runat="server" ID="preferenceReportGrd" AutoGenerateColumns="false"
AutoGenerateSelectButton="false" CaptionAlign="Top" EnableSortingAndPagingCallbacks="false" HorizontalAlign="left" CssSelectorClass="gvwPrefReport">
<Columns>
<asp:BoundField ReadOnly="true" DataField="ClientName" HeaderText="Company Name" />
<asp:BoundField ReadOnly="true" DataField="typeDescription" HeaderText="Preference" />
<asp:BoundField ReadOnly="true" DataField="defaultValue" HeaderText="Default Preference" />
<asp:BoundField ReadOnly="true" DataField="previousPreferenceValue" HeaderText="Previous Preference" />
<asp:BoundField ReadOnly="true" DataField="selectedValue" HeaderText="New Preference" />
<asp:BoundField ReadOnly="true" DataField="lastUpdated" HeaderText="Date Last Edited" />
</Columns>
</asp:GridView>
<div>
<user:MsgLine runat="server" ID="MsgLine1" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
I am trying to export this gridview out to excel. There is a button which the user clicks on it calls the on_click method for that button and in this on_click i have the following:
string attachment = "attachment; filename=Employee.xls";
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/excel";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
preferenceReportGrd.RenderControl(htextw);
Response.Write(stw.ToString());
Response.End();
I get nothing from this tried debugging it seems that when i mouse over stw.tostring() all the values for the gridview are there but nothing gets written out.
Yes. within the update panel tag excel export is not working. I face the same problem.
To solve this use the following code in end of the update panel tag
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="BtnExport" />
</Triggers>
</asp:UpdatePanel>
it works even within the update panel also
If the GridView and/or the button is within in update panel with an async postback, I do not believe you can change the response headers or information. Try running it again with a full postback on the button trigger and see what happens. Your code did not look incorrect, but I've not tried it...
Take a look at this samples...
1. c-sharpcorner
2. Matt Berseth
3. Code Project
Check your content types and for a PostBackTrigger on the exporting button.
For Excel 2003
Response.ContentType = "application/vnd.ms-excel
For Excel 2007
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
You can check out this blog post for the source of my content types.
EDIT: From your comments:
You need to set a PostBackTrigger on the panel that contains the button doing the export, not the panel that contains the GridView.
EDIT EDIT: Your file-is-not-what-it-says-it-is error is due to a feature called Extension Hardening, present in Excel 2007. Check this StackOverflow question for more info; I linked to a blog post describing the reasoning for this error and a possible workaround.
The way I was able to work around this in a simple page that I was working on was to have a hidden gridview outside of the updatepanel and set it equal to the gridview in the update panel so that they are the same (except for the new one being hidden). Then export this hidden grid to Excel the same way that you were doing it before.
One issue with doing it this way is that the export hyperlink needs to be outside of the update panel as well which means that you might not be able to put the export hyperlink where you want it.
Granted this is probably not the best way to do it, it got me around this issue at the time. Hope it helps.

Resources