Hi,
I have a weird issue with rad listbox filtering. I tried to attach that, but the post didn't allowed me to. I will write the code here.
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
ID
=
"script1"
runat
=
"server"
></
telerik:RadScriptManager
>
<
asp:Panel
ID
=
"pnlMainFields"
runat
=
"server"
>
<
table
>
<
tr
>
<
td
>
<
table
>
<
tr
>
<
td
>
<
h3
>Available Fields</
h3
>
<
table
>
<
tr
>
<
td
>
<
asp:CheckBox
ID
=
"chkShowAdvanced"
runat
=
"server"
Text
=
"Show advanced columns"
AutoPostBack
=
"true"
/>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
telerik:RadTextBox
ID
=
"tbAvailableFilter"
runat
=
"server"
Width
=
"187px"
EmptyMessage
=
"Search ..."
autocomplete
=
"off"
onkeyup
=
"filterList();"
/>
<
telerik:RadButton
ID
=
"rbtnClear"
runat
=
"server"
Width
=
"22px"
AutoPostBack
=
"false"
OnClientClicking
=
"rbtnClear_OnClientClicking"
>
<
Icon
PrimaryIconCssClass
=
"rbClear"
/>
</
telerik:RadButton
>
</
td
>
</
tr
>
</
table
>
</
td
>
<
td
></
td
>
<
td
>
<
h3
>Selected Fields</
h3
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"vertical-align:top"
>
<
telerik:RadListBox
ID
=
"lstAvailable"
runat
=
"server"
Height
=
"250px"
Width
=
"250px"
AllowTransfer
=
"true"
AllowTransferOnDoubleClick
=
"true"
TransferToID
=
"lstSelected"
EnableDragAndDrop
=
"true"
OnClientTransferring
=
"lstAvailable_OnClientTransferring"
ButtonSettings-ShowTransferAll
=
"false"
SelectionMode
=
"Multiple"
/>
</
td
>
<
td
style
=
"vertical-align: middle"
>
<
asp:ImageButton
ID
=
"btnMoveToSelected"
runat
=
"server"
ImageUrl
=
"/images/app/Button-Add.jpg"
Visible
=
"false"
/><
br
/>
<
asp:ImageButton
ID
=
"btnMoveToAvailable"
runat
=
"server"
ImageUrl
=
"/images/app/Button-Remove.jpg"
Visible
=
"false"
/>
</
td
>
<
td
>
<
telerik:RadListBox
ID
=
"lstSelected"
runat
=
"server"
Height
=
"250px"
Width
=
"250px"
EnableDragAndDrop
=
"true"
AllowReorder
=
"true"
/>
</
td
>
</
tr
>
</
table
>
</
td
>
</
tr
>
<
tr
>
<
td
></
td
>
</
tr
>
<
tr
>
<
td
></
td
>
</
tr
>
</
table
>
</
asp:Panel
>
</
div
>
<
telerik:RadCodeBlock
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function filterList() {
var listbox = $find("<%= lstAvailable.ClientID%>");
var textbox = $find('<%= tbAvailableFilter.ClientID %>');
clearListEmphasis(listbox);
createMatchingList(listbox, textbox.get_textBoxValue());
}
// Remove emphasis from matching text in ListBox
function clearListEmphasis(listbox) {
var re = new RegExp("</{0,1}em>", "gi");
var items = listbox.get_items();
var itemText;
items.forEach
(
function (item) {
itemText = item.get_text();
item.set_text(itemText.replace(re, ""));
}
)
}
// Emphasize matching text in ListBox and hide non-matching items
function createMatchingList(listbox, filterText) {
if (filterText != "") {
filterText = escapeRegExCharacters(filterText);
var items = listbox.get_items();
var re = new RegExp(filterText, "i");
items.forEach
(
function (item) {
var itemText = item.get_text();
if (itemText.match(re)) {
item.set_text(itemText.replace(re, "<
em
>" + itemText.match(re) + "</
em
>"));
item.set_visible(true);
}
else {
item.set_visible(false);
}
}
)
}
else {
var items = listbox.get_items();
items.forEach
(
function (item) {
item.set_visible(true);
}
)
}
}
function lstAvailable_OnClientTransferring(sender, eventArgs) {
// Transferred items retain the emphasized text, so it needs to be cleared.
clearListEmphasis(sender);
// Clear the list. Optional, but prevents follow up situation.
clearFilterText();
createMatchingList(sender, "");
}
function rbtnClear_OnClientClicking(sender, eventArgs) {
clearFilterText();
var listbox = $find("<%= lstAvailable.ClientID %>");
clearListEmphasis(listbox);
createMatchingList(listbox, "");
}
// Clears the text from the filter.
function clearFilterText() {
var textbox = $find('<%= tbAvailableFilter.ClientID %>');
textbox.clear();
}
// Escapes RegEx character classes and shorthand characters
function escapeRegExCharacters(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
</
script
>
</
telerik:RadCodeBlock
>
</
form
>
The code to populate data is
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
If
Not
Page.IsPostBack
Then
ListAvailableFields()
End
If
End
Sub
Private
Sub
ListAvailableFields()
lstAvailable.Items.Clear()
For
temp
As
Integer
= 1
To
10
Dim
name
As
String
= $
"Enabled {temp}"
lstAvailable.Items.Add(
New
Telerik.Web.UI.RadListBoxItem(name, name))
name = $
"Disabled {temp}"
lstAvailable.Items.Add(
New
Telerik.Web.UI.RadListBoxItem(name, name))
Next
End
Sub
Now, type something in the list. For example, type "Enabled" so that it filters all enabled columns.
Once filtered , Click on first search result, HOLD down the shift key and Click on the last item in the grid to select ALL values in the listbox.
Click on the right arrow and it should Copy all the selected values to the right grid.
However, you will notice that it copied over Enabled xx as well as Disabled xx which was not in the search result.
That is a problem, I filtered only "Enabled" but it moved "Disabled" as well.
It seems list is hiding the items only, but when you select multiple using SHIFT key, it includes them. Selecting as many items as you can, using one at a time, will not be an issue.
Any thoughts on this should be appreciated.
Thank you
I have a usercontrol as my edit form, and a property called DataItem that gets bound, one item of which is called ItemID and is bound to a HiddenField.
<
asp:HiddenField
ID
=
"itemID"
runat
=
"server"
Visible
=
"false"
Value='<%# DataBinder.Eval(Container, "DataItem.ItemID") %>' />
Everything seems good, form renders. I have two controls I call by button click, and in those handlers I can get the value of the HiddenField ItemID to pass its value along in a url.
"&ItemID=" & itemID.Value.ToString() &
The problem comes in when in Page_Load, I want to restrict whether to show these controls or not by the value of ItemID. In Page_Load, itemID.Value is empty, presumably because the page hasn't loaded yet, and while _dataItem seems to exist, it has no fields yet. Is there an event I can tie into to say 'run this after _dataItem has been bound'? There is OnDataBound, but the note on the documentation page says only useful with client side data binding and my solution uses NeedsDataSource.
I have a row of totals in my grid. I add a custom footer to my grid where I add a grand total for 3 total columns to the last cell. I add a <br /> and to all the other cells as shown below.
if (e.Item is GridFooterItem)
{
GridFooterItem footerItem = (GridFooterItem)e.Item;
{
double a= 0;
double b= 0;
double c= 0;
double sumA = 0;
double sumB = 0;
double sumC = 0;
double total = 0;
foreach (GridDataItem item in e.Item.OwnerTableView.Items)
{
a= Double.Parse(item["A"].Text, NumberStyles.Currency);
sumA += a;
b= Double.Parse(item["B"].Text, NumberStyles.Currency);
sumB += b;
c= Double.Parse(item["C"].Text, NumberStyles.Currency);
sumC += c;
}
total = sumA + sumB + sumC;
footerItem["A"].Text = sumA .ToString("c2") + "<
br
/> ";
footerItem["B"].Text = sumB .ToString("c2") + "<
br
/> ";
footerItem["C"].Text = sumC.ToString("c2") + "<
br
/>" + total.ToString("c2");
}
on my excel export the blank cell does not show. It seems excel is ignoring the line break and empty cell and just bottom aligning the total for me. See attached.
I even tried the approach in some other threads to replace the <br /> with but that just takes the new line away completely.
protected void grid_GridExporting(object sender, GridExportingArgs e)
{
RadGrid grid = (RadGrid)sender;
e.ExportOutput = e.ExportOutput.Replace("<
br
/>", "
");
}
Dim editedItem As GridEditableItem = Nothing
If RadGrid1.MasterTableView.IsItemInserted Then
editedItem = RadGrid1.MasterTableView.GetInsertItem()
End If
If IsNothing(editedItem) Then
editedItem = RadGrid1.EditItems.Item(0)
End If
Dim ddl As DropDownList = CType(editedItem.FindControl("ddlId"), DropDownList)
ddl.Items.Insert(0, newValue)
ddl.SelectedValue = newValue
I'm currently using R2 2018 SP1 and I'm experiencing a display issue with the grouping header. In my project, I have two grids that are very similar. Both use grouping but one one grid has static headers.
When I use static headers, the grouping header show the column grid lines (i.e. row renders a <TD> for each column). But when I just simply remove theUseStaticHeaders="true" attribute, the grouping row is displayed as expected without the column grid lines (i.e. row renders with as one TD and a colspan attribute). Also note that I'm using the WebBlue theme.
See the attached screenshots displaying both situations.
I was unable to find this specific situation in the current grid demo so I was unable to confirm if this is a problem in the current release.
Thanks
Loy.