search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

The Apply link is not working for Fast Filter

Asked by Kathy
10 years ago.

Hi Dan,
Hope all is well.
I'm am having problems with the javascript:filter(); for the the apply link for the Scheduler. I searched throughout the site and can't seem to find out what I am doing wrong. Below is what I have:
Default.aspx:
<code>
/* Fast filter helpers */
function clear() {
var filterBox = document.getElementById("TextBoxFilter");
filterBox.value = '';
filter();
}
function filter() {
var filterBox = document.getElementById("TextBoxFilter");
var filterText = filterBox.value;
dps1.clientState = {"filter": filterText};
dps1.commandCallBack("filter");
}
function key(e) {
var keynum = (window.event) ? event.keyCode : e.keyCode;
if (keynum === 13) {
filter(); return false;
}
return true;
}
<div style="margin-bottom:5px"><b>Fast filter:</b>
<input type="text" id="TextBoxFilter" onkeypress="return key(event);" />&nbsp;
<a href="javascript:filter();" style="font-weight:bold">Apply</a>
&nbsp;<a href="javascript:clear();">Clear</a></div>
</code>

Default.aspx.cs:
<code>
private void setDataSourceAndBind()
{
// ensure that filter is loaded
string filter = (string)DayPilotScheduler1.ClientState["filter"];
DayPilotScheduler1.DataSource = getData(DayPilotScheduler1.StartDate, DayPilotScheduler1.EndDate.AddDays(1), filter);
DayPilotScheduler1.DataBind();
}

private DataTable getData(DateTime start, DateTime end, string filter)
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["_____"].ConnectionString);
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT DISTINCT [id], [name], [eventstart], [eventend], [resource_id] FROM event WHERE NOT ((eventend <= @start) OR (eventstart >= @end))";
cmd.Parameters.AddWithValue("@start", start);
cmd.Parameters.AddWithValue("@end", end);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adapter.Fill(dt);
String select;
if (String.IsNullOrEmpty(filter))
{
select = String.Format("NOT (([eventend] <= '{0:s}') OR ([eventstart] >= '{1:s}'))", start, end);
}
else
{
select = String.Format("NOT (([eventend] <= '{0:s}') OR ([eventstart] >= '{1:s}')) and [name] like '%{2}%'", start, end, filter);
}
//throw new Exception(select);
DataRow[] rows = dt.Select(select);
DataTable filtered = dt.Clone();
foreach (DataRow r in rows)
{
filtered.ImportRow(r);
}
return filtered;
}

case "filter":
//string filter = (string)e.Data;
//DayPilotScheduler1.DataSource = getData(DayPilotScheduler1.StartDate, DayPilotScheduler1.EndDate.AddDays(1), filter);
setDataSourceAndBind();
DayPilotScheduler1.DataBind();
DayPilotScheduler1.Update(CallBackUpdateType.EventsOnly);
return; // note that the binding done inside the case section here
</code>

When I click on Apply nothing happens. The clear link works.
Please advise thanks!

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.