手动更改kendo ui工具栏切换按钮不起作用(manually change kendo ui toolbar toggle button not working)
Kendo UI版本2015.2.805
工具栏切换按钮
每个文档:
var checked = true; var tb = $("#filter_toolbar").data("kendoToolBar"); tb.toggle("#mostRecent", checked);
应该切换按钮,如果checked = true且off为checked = false,但实际上它会切换按钮,而不管检查的值如何。
既然如此,我可以测试k-state-active来确定我是否应该切换它,但是我在这里做错了什么?
Kendo UI Version 2015.2.805
Toolbar toggle button
per docs:
var checked = true; var tb = $("#filter_toolbar").data("kendoToolBar"); tb.toggle("#mostRecent", checked);
should toggle button on if checked=true and off is checked=false, however what it actually does is toggle the button irregardless of the value of checked.
That being the case,I can test for k-state-active to determine if I should toggle it or not but am I doing something wrong here?
原文:https://stackoverflow.com/questions/42216911
最满意答案
该错误不是由
Random.Next
引起的,因为即使Next
由于循环条件i < numberOfNumerics
返回4,也只循环3个数字。 所以这是正确的。错误是由错误的逻辑引起的。 你用:
builder.Replace(builder[replaceIndex],d);
用您的数字代替所有出现的字母。 你想要使用:
builder[replaceIndex] = d;
但是你应该存储已经被替换的索引,否则你可以替换它们:
var replacedIndexes = new HashSet<int>(); for (int i = 0; i < numberOfNumerics; i++) { int replaceIndex = random.Next(0, builder.Length); while (!replacedIndexes.Add(replaceIndex)) replaceIndex = random.Next(0, builder.Length); char d = digits[random.Next(0, digits.Length)]; builder[replaceIndex] = d; }
The error is not caused by
Random.Next
since you loop only 3 numbers even ifNext
can return 4 because of your loop conditioni < numberOfNumerics
. So this is correct.The error is caused by a wrong logic. You use:
builder.Replace(builder[replaceIndex],d);
That replaces all occurrences of a letter with your digit. You want to use:
builder[replaceIndex] = d;
But you should store the already replaced indexes otherwise you could replace the same:
var replacedIndexes = new HashSet<int>(); for (int i = 0; i < numberOfNumerics; i++) { int replaceIndex = random.Next(0, builder.Length); while (!replacedIndexes.Add(replaceIndex)) replaceIndex = random.Next(0, builder.Length); char d = digits[random.Next(0, digits.Length)]; builder[replaceIndex] = d; }
相关问答
更多-
生成5位随机引脚(Generating a Random Pin of 5 Digits)[2022-05-07]
我建议使用SecureRandom类生成随机数,然后因为它需要5位数使用random.nextInt(100000)创建0到99999之间的随机数,这里0是包含的,100000是独占的,然后将其格式化为5数字加零。 SecureRandom random = new SecureRandom(); int num = random.nextInt(100000); String formatted = String.format("%05d", num); System.out.println(forma ... -
Python返回的uuid实际上是一个类,因此您可以轻松地以不同的格式获取它: >>> import uuid >>> uuid.uuid4().int 27168693431722041803402778536822837233 这是UUID类型的在线帮助。 你想要int属性。 >>> help(uuid.UUID) Help on class UUID in module uuid: class UUID(builtins.object) | Instances of the UUID clas ...
-
由于你的数学,已经逆转了,不需要交换变量。 所以你只需要创建一个新的int: int reversedNumber = int.Parse(string.Concat(digit1, digit2, digit3, digit4)); 如果你想要一个没有数学的更简洁的版本: int reversedNumber = int.Parse(string.Concat(txtNumber.Text.TrimStart('0').Reverse())); Theay are already reversed ...
-
C# - 生成最多3位数字的随机用户名有时会输入4位数字(C# - Generating random username with up to 3 digits puts 4 digits sometimes)[2022-03-24]
该错误不是由Random.Next引起的,因为即使Next由于循环条件i < numberOfNumerics返回4,也只循环3个数字。 所以这是正确的。 错误是由错误的逻辑引起的。 你用: builder.Replace(builder[replaceIndex],d); 用您的数字代替所有出现的字母。 你想要使用: builder[replaceIndex] = d; 但是你应该存储已经被替换的索引,否则你可以替换它们: var replacedIndexes = new HashSet( ... -
那么,你可以写: int num; do { num = SSN.Next(100000000, 999999999); } while (num >= 666000000 && num < 667000000); (我最初也使用了字符串比较,但由于我们总是有9位数字,所以我们可以轻松地进行数字比较。) Well, you could write: int num; do { num = SSN.Next(100000000, 999999999); } while (num >= 66600 ...
-
一个6位数的随机数字将是: int number = arc4random_uniform(1000000); 但是,这给出了一个从0到999,999的数字。 听起来你想要一个从100,000到999,999的随机数字。 所以这样做: int number = arc4random_uniform(900000) + 100000; A random number with 6 digits would be: int number = arc4random_uniform(1000000); But ...
-
如何创建一个随机的16位数字,具体的第一个数字?(How to create a random 16 digits number, with specific first digits?)[2023-06-14]
首先,您需要生成一个随机的14位数字,就像您所做的那样: long first14 = (long) (Math.random() * 100000000000000L); 然后在开头添加52 。 long number = 5200000000000000L + first14; 另一种方式同样可以工作,并且会节省内存,因为Math.random()创建了一个内部Random对象: //Declare this before you need to use it java.util.Random rn ... -
你的while条件是Math.Abs(n) > 1 ,但是在10的情况下,第一次只有大于1。 您可以将此检查更改为>=1 ,并且可以解决您的问题。 do { n = n / 10; i++; } while(Math.Abs(n) >= 1); Your while condition is Math.Abs(n) > 1, but in the case of 10, you are only greater than 1 the first time. You could change ...
-
你很亲密 但问题在于你是从“半分类”数组中随机选择的,而那时真正需要的是选择随机排列。 一种方法是使用Fisher-Yates shuffle 。 所以将它与你工作的代码相结合:(未经测试) for (int i = 0; i < 3; i++) { stringChars[i] = alphabetic[random.Next(alphabetic.Length)]; } for(int i = 3; i< stringChars.Length; i++) { stringChars[i] ...
-
import Foundation func random9DigitString() -> String { let min: UInt32 = 100_000_000 let max: UInt32 = 999_999_999 let i = min + arc4random_uniform(max - min + 1) return String(i) } import Foundation func random9DigitString() -> String ...