I would like a textbox to show nothing if the value coming from the database is NULL.
Currently, it is a number so it shows '0'. If the value is '0', I would like it to show nothing.
Using the GetValueJavaScript attribute, can you write add an if statement to the this attribute?
Thanks.
Hello Gloria,
Thank you for using our forums.
By default our WebDataGrid is showing null values as empty strings. I don't know what do you mean by saying textbox? Do you mean some of our editor providers? Could you please share with me more information about your concerns, like exact product version and some code snippet of your Grid.
Looking forward to hearing from you.
Sorry for the confusion...
I am setting values in my RowEditing Template by binding using the ClientBindings. Below is what I am currently doing for the latitude and longitude values:
<Behaviors> <ig:RowEditingTemplate CancelButton="buttonCancelEdit" OKButton="buttonOKEdit"> <ClientBindings> <ig:RowEditingClientBinding ColumnKey="Lat" ControlID="txtLatEdit" GetValueJavaScript="$get({ClientID}).value" SetValueJavaScript="$get({ClientID}).value={value}" /> <ig:RowEditingClientBinding ColumnKey="Long" ControlID="txtLongEdit" GetValueJavaScript="$get({ClientID}).value" SetValueJavaScript="$get({ClientID}).value={value}" /> </ClientBindings> <Template> <table id="tblEdit" style="width: 800px; border: 1px solid Black; background-color:White;"> <tr> <td align="left" style="width: 15%;"> <asp:Label ID="lblLatEdit" runat="server" Text="Latitude: " /> </td> <td align="left" style="width: 35%;"> <asp:TextBox ID="txtLatEdit" runat="server" Width="200px" /> <asp:MaskedEditExtender ID="MaskedEditExtender1" runat="server" MaskType="Number" TargetControlID="txtLatEdit" Mask="99.999999999" AcceptNegative="Left"> </asp:MaskedEditExtender> </td> <td align="left" style="width: 15%;"> <asp:Label ID="lblLongEdit" runat="server" Text="Longitude: " /> </td> <td align="left" style="width: 35%;"> <asp:TextBox ID="txtLongEdit" runat="server" Width="200px" /> <asp:MaskedEditExtender ID="MaskedEditExtender2" runat="server" MaskType="Number" TargetControlID="txtLongEdit" Mask="99.999999999" AcceptNegative="Left"> </asp:MaskedEditExtender> </td> </tr> </table> </Template></ig:RowEditingTemplate></Behaviors>
This works fine if there are values in the Lat and Long elements. However, if the values from the database are NULL, they are shown as '0'. I want NULL values to display as an empty string, not 0.
Can I add a conditional statement in the attribute, GetValueJavaScript to set the TextBox for Lat and Long to the empty string if the values are NULL?
Yes, there is a way, you can try this approach:
<ig:RowEditingClientBinding ColumnKey="Date" ControlID="control_Date" GetValueJavaScript="$get({ClientID}).value" SetValueJavaScript="$get({ClientID}).value={value} == null ? '' : {value}" />
Let me know about the results.
Thanks for replying.
When I use your code, I get an error "Reference Error: Undefined".
This is my code:
<ig:RowEditingClientBinding ColumnKey="Lat" ControlID="txtLatEdit" GetValueJavaScript="$get({ClientID}).value" SetValueJavaScript="$get({ClientID}).value={value} == null ? '' : {value}" />
Hello,
I have created a sample for you in order to show you my approach. I hope you will benefit from it. If the issue still persist, could you please make the necessary changes in order to reproduce it into the sample and return it back to me.
Thanks for your reply.
Unfortunately, I cannot run your application. You are using a later version of the webdatagrid. I am using v11.2. Your version is v14.2.
Is the ability to set the javascript something that was added to a later version of the datagrid and not available in v11.2?
The only other difference I see is that my control is a textbox and your controls are either Date fields, currency or integer fields.
Thanks,
Gloria
Hi,
The classic controls are retired and no longer supported. They are also not included in NetAdvantage versions 11.2 and above. I would suggest you to migrate to the new controls based on our Aikido framework. Here you can find more information on the matter:
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2013.1/CLR4.0/html/Classic_Control_Migration_Guide.html
http://ko.infragistics.com/community/blogs/taz_abdeali/archive/2010/03/04/asp-net-product-changes.aspx