I'm becoming crazy with Kendo UI AutoComplete component. I'm using my own functions to access data with jQuery, so I have to set the AutoComplete dataSource.transport.read as a function. The code is something like this.
minLengthAtocomplete = 3;
$('#autocomplete').kendoAutoComplete({
minLength : 3,
filter : "contains",
dataValueField : "key",
dataTextField : "value",
dataSource : new kendo.data.DataSource({
transport : {
read : _OnTransportRead
},
schema : {
/* object schema */
}
})
});
function _OnTransportRead(e) {
var text = $.trim(e.data.filter.filters[0].value);
if (text && text.length >= minLengthAtocomplete) {
_GetUsers(
text,
function onSuccess(data) {
var users = [];
/* sets users with info in data */
e.success(users);
},
function onError(error) {
/* stuff with error */
}
);
}
}
function _GetUsers(userName, onSuccess, onError) {
/* Ajax to get users from DB */
}
This code runs perfectly, but dataSource.transport.read is called only the once. I do a first search with the text 'michae' and AutoComplete component runs its dataSource.transport.read as expected. Then, I add a one more letter to search for 'michael', and dataSource.transport.read is never called again. Is so frustrating!
I tried using autoSync dataSource property, manual dataSource Sync, set new dataSource objects on AutoComplete dataBound, but no luck.
What am I doing wrong? What am I forgetting?
Thanks in advance.
You should enable serverFiltering in order for the data source to make requests every time.
$('#autocomplete').kendoAutoComplete({
minLength : 3,
filter : "contains",
dataValueField : "key",
dataTextField : "value",
dataSource : new kendo.data.DataSource({,
serverFiltering: true,
transport : {
read : _OnTransportRead
},
schema : {
/* object schema */
}
})
});
Related
I have a Scala Program with JavaFX GUI. When I fire a button, I disable my button and change a label text before calling a function that takes several tens of seconds to execute (RobotWebCore.runSearch()). The problem is that the GUI do not display the changes I bring to it before calling my function (but only after) :/
Here my code:
class GuiController extends Initializable {
#FXML
var GUI : VBox = null;
#FXML
var RQ_TEXT_FIELD : TextField = null;
#FXML
var SEARCH_BUTTON : Button = null;
#FXML
var STATE_LABEL : Label = null;
override def initialize(location : URL, resources : ResourceBundle ) = {
Printer.activeGui = true;
GuiController.instance = this;
SEARCH_BUTTON.setOnMousePressed(e => runSearch());
}
def setStateMessage(message: String) = STATE_LABEL.setText(message);
private def runSearch() = {
val p = ExpressionParser.LocalParser.parse(RQ_TEXT_FIELD.getText);
if (p.successful) {
GUI.setCursor(Cursor.WAIT);
SEARCH_BUTTON.setDisable(true);
setStateMessage("Recherche en cours");
RobotWebCore.runSearch(p.get);
SEARCH_BUTTON.setDisable(false);
GUI.setCursor(Cursor.DEFAULT);
} else {
setStateMessage("Requête invalide ! Exemple : (chat and chat) or perroquet");
}
}
}
We would like to implement AutoCompleteTextField field, once user has selected the field from AutoComplete result, then system would auto populate on other text field, i have used the component AjaxFormComponentUpdatingBehavior (blur), however this will take effect on every text input from AutoCompleteTextField field, but if i change to AjaxFormComponentUpdatingBehavior (change), it doesnt work.
Below is the sample code:
AutoCompleteTextField<String> field_postcode = new AutoCompleteTextField<String>("field_postcode",
new PropertyModel<String>(getModelObject(), "wAdditionalInfo.postal"), autoCompleteRenderer) {
private static final long serialVersionUID = 1L;
#Override
protected Iterator<String> getChoices(String input) {
if (Strings.isEmpty(input)) {
List<String> emptyList = Collections.emptyList();
return emptyList.iterator();
}
List<String> choices = new ArrayList<String>();
List<Postcode> postcodeList = getProfileManager().findAllPostcodeByPostcode(input);
for (Postcode p : postcodeList) {
String postcode = p.getPostcode();
if (postcode.startsWith(input)) {
choices.add(p.getPostcode());
if (choices.size() == 10) {
break;
}
}
}
return choices.iterator();
}
};
field_postcode.setRequired(true);
field_postcode.add(new AjaxFormComponentUpdatingBehavior("blur"){
private static final long serialVersionUID=-1107858522700306810L;
#Override protected void onUpdate( AjaxRequestTarget target){
Postcode postcode = getProfileManager().findPostcodeByPostcode(field_postcode.getInput());
if (postcode != null) {
City city = postcode.getCity();
State state = city.getState();
field_city.setModelObject(city.getCity());
ddl_state.setModelObject(state);
if (isDisplayTip) {
//isDisplayTip true mean is from widrawal webform
isReadonly = true;
} else {
field_city.setEnabled(false);
}
ddl_state.setEnabled(false);
} else {
if (isDisplayTip) {
isReadonly = false;
} else {
field_city.setEnabled(true);
}
ddl_state.setEnabled(true);
}
target.add(field_city, ddl_state);
}
}
);
Is there any api from wicket to achieve this? We need to have something when user select the option from Auto complete, then it only onUpdate method of AjaxFormComponentUpdatingBehavior
According to https://github.com/apache/wicket/blob/cbc237159c4c6632b4f7db893c28ab39d1b40ed4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js#L620 it should trigger change event on the HTMLInputElement and thus notify you on the server side.
Use the browser debugger to see whether https://github.com/apache/wicket/blob/cbc237159c4c6632b4f7db893c28ab39d1b40ed4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js#L453 is executed and whether it leads to an Ajax call with the value in the parameters.
I am trying to run background service in UWP application. I am first checking if application has background permission. If yes then I am registering the service for running.
This code was working fine until I updated Visual Studio along with Windows 10 SDK to Creators Update version. Now I can't figure out if this update changes things for registering background service.
using System;
using Windows.ApplicationModel.Background;
using BackgroundService;
using SampleApp.Config;
namespace SampleApp.Background
{
class BackgroundClass
{
LocalConfig LC = new LocalConfig();
public async void RequestBackgroundAccess()
{
var result = await BackgroundExecutionManager.RequestAccessAsync();
switch (result)
{
case BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity:
break;
case BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity:
break;
case BackgroundAccessStatus.Denied:
break;
case BackgroundAccessStatus.Unspecified:
break;
}
}
public async void RegisterBackgroundSync()
{
var trigger = new ApplicationTrigger();
var condition = new SystemCondition(SystemConditionType.InternetAvailable);
if (!LC.BackgroundSyncStatusGET())
{
var task = new BackgroundTaskBuilder
{
Name = nameof(BackgroundSync),
CancelOnConditionLoss = true,
TaskEntryPoint = typeof(BackgroundSync).ToString(),
};
task.SetTrigger(trigger);
task.AddCondition(condition);
task.Register();
LC.BackgroundSyncStatusSET(true);
}
await trigger.RequestAsync(); //EXCEPTION HAPPENS AT THIS LINE
}
public void RegisterBackgroundService(uint time)
{
var taskName = "BackgroundService";
foreach (var unregisterTask in BackgroundTaskRegistration.AllTasks)
{
if (unregisterTask.Value.Name == taskName)
{
unregisterTask.Value.Unregister(true);
}
}
if(time != 0)
{
var trigger = new TimeTrigger(time, false);
var condition = new SystemCondition(SystemConditionType.InternetAvailable);
var task = new BackgroundTaskBuilder
{
Name = nameof(BackgroundService),
CancelOnConditionLoss = true,
TaskEntryPoint = typeof(BackgroundService).ToString(),
};
task.SetTrigger(trigger);
task.AddCondition(condition);
task.Register();
}
}
}
}
Now while requesting I am checking if background service is registered keeping issues for re-registration. I am getting following exception
System.Runtime.InteropServices.COMException occurred
HResult=0x80004005
Message=Error HRESULT E_FAIL has been returned from a call to a COM component.
Source=Windows
StackTrace:
at Windows.ApplicationModel.Background.ApplicationTrigger.RequestAsync()
at SampleApp.Background.BackgroundClass.d__2.MoveNext()
Please Help
Had this same problem, was in my Windows 10 Privacy Settings.
System Settings => Privacy Settings
In the left-hand menu choose Background apps.
Check to make sure your app hasn't been blocked from running background tasks.
thank you for helping.
First, I created a form with a (user defined) property.
as see below
public partial class nfrmtableitem : Form
{
private DataRow _datarow;
public DataRow U_Table_Row { get { return _datarow; } set { _datarow = value; } }
public nfrmtableitem()
{
InitializeComponent();
}
}
And I create second form with property as type of Form.
as see below
public partial class nftableshow : Form
{
private DataTable _datatable;
public DataTable U_DataTable { get { return _datatable; } set { _datatable = value; } }
private Form _inputform1;
public Form U_DGV_InputForm1 { get { return _inputform1; } set { _inputform1 = value; } }
}
when call it:
any where
nftableshow newfrmtableshow = new nftableshow()
{
Name = "newfrmtableshow",
Text = "Show the table",
MdiParent = this,
U_DGV_InputForm1 = new nfrmtableitem(),
};
newfrmtableshow.Show();
But I can not use the first form property in second form.
and the property is not in instance.
//the button in second form
private void button1_Click_Click(object sender, EventArgs e)
{
Form f1 = _inputform1 as Form;
/*
* {
* U_Table_Row = db.maindataset.Tables["customer"].NewRow(),
* };
*/
f1.Show();
}
Question:
How can I use the First form with specific (user defined) property in second form.
Regards
You should probably use dot notation to access the property of the first form. Try using
//the button in second form
private void button1_Click_Click(object sender, EventArgs e)
{
Form f1 = _inputform1 as Form;
{
f1.U_Table_Row = db.maindataset.Tables["customer"].NewRow(),
};
f1.Show();
}
I want to create a form field for a login script that allows either a username or an email address to be entered.
I have a validator
$loginName = new Zend_Form_Element_Text('loginName');
$loginName->addValidators(array('Alnum', 'EmailAddress');
Which does not work (because it seems to validate Alnum AND EmailAddress). I would like to validate Alnum OR EmailAddress.
Any suggestions on how to do this?
You have two options. You can either use a Regex validator, or you can write a custom validator which itself uses the Alnum and Email validators.
http://framework.zend.com/manual/en/zend.validate.writing_validators.html
The second option would look something like this:
class My_Validate_Field extends Zend_Validate_Abstract
{
protected $_messageTemplates = array(
'alnumemail' => "'%value%' is not an alphanumeric string or email address"
);
public function isValid($value)
{
$alnum = new \Zend_Validate_Alnum();
$email = new \Zend_Validate_EmailAddress();
$valid = $alnum->isValid( $value ) || $email->isValid( $value);
if( !$valid ) {
$this->_error();
}
return $valid;
}
}