从Google文档表单中订购电子表格中的列(Order columns in a spreadsheet from a google docs form)
你不能从一边到另一边移动表中的列,因为这样做会破坏表中的结构。 这是谷歌支持和/或帮助页面说的。
我的问题是,如果我在谷歌文档中创建一个。 我无意中创造了一个问题,我应该早些时候创建,然后将问题移到表单上。 该列不会在电子表格中移动。
所以我的表单电子表格现在看起来搞砸了。 有没有办法解决这个问题,而无需再次输入我的所有问题(89)。 我在表格中没有任何结果。 所以我正在寻找一个再生表选项,或类似的东西。
you can't move columns in the table from side to side, since doing so would disrupt the structure from the table. This is wat google support and/or help pages says.
My problem is that if i create a from in google docs. And i accidently create a question that i should of created earlier and then i move the question up the form. The column doesn't move in the spreadsheet.
So my form spreadsheet looks messed up now. Is there a way to fix this without typing all my questions(89) again. I don't have any results in the sheet yet. So i'm looking for a regenerate sheet option, or something like that.
原文:https://stackoverflow.com/questions/11205864
最满意答案
我不确定是否可以在不知道数组是如何构建的情况下回答问题。 一个问题是For-in循环变量是一个NSFastEnumerationIterator,因此它需要向下转换为你想要它的那种“东西”。 你可能已经这样做了,这只是为了将来的参考。
话虽如此,我制作了一些代码并将其分解了一下 - 也许它会指向正确的方向。
下面的代码通过.value读入所有节点,然后遍历快照并将每个子节点存储在数组中作为FDataSnapshot。 然后代码迭代该数组并从存储在数组中的每个快照打印“guardian”。
我还包括你的代码来打印guardianID,它也可以工作,所以我的猜测是问题在于如何最初填充数组或在此行中
用于self.guardians中的快照
因为快照是NSFastEnumerationIterator
let ref = self.myRootRef.child(byAppendingPath: "guardian_node")! ref.observe(.value, with: { snapshot in if ( snapshot!.value is NSNull ) { print("not found") } else { var guardianArray = [FDataSnapshot]() for child in snapshot!.children { let snap = child as! FDataSnapshot //downcast guardianArray.append(snap) } for child in guardianArray { let dict = child.value as! NSDictionary let thisGuardian = dict["guardian"]! print(thisGuardian) //your code let guardianID = (child.value as? NSDictionary)?["guardian"] as? NSString print(guardianID!) } } })
*这是Swift 3和Firebase 2.x,但概念是相同的。
I am not sure if the question can be answered without knowing how the array is built. One gotcha is the For-in loops variable is a NSFastEnumerationIterator so it needs to be downcast to what kind of 'thing' you want it to be. You may have done that so this is just for future reference.
That being said, I crafted up some code and broke it down a bit - maybe it will point you in the right direction.
The code below reads in all nodes by .value and then iterates over the snapshot and stores each child in an array as a FDataSnapshot. Then the code iterates over that array and prints the 'guardian' from each snapshot stored in the array.
I also included your code to print the guardianID and it works as well so my guess is the problem lies with how the array is being initially populated or in this line
for snapshot in self.guardians
as the snapshot is a NSFastEnumerationIterator
let ref = self.myRootRef.child(byAppendingPath: "guardian_node")! ref.observe(.value, with: { snapshot in if ( snapshot!.value is NSNull ) { print("not found") } else { var guardianArray = [FDataSnapshot]() for child in snapshot!.children { let snap = child as! FDataSnapshot //downcast guardianArray.append(snap) } for child in guardianArray { let dict = child.value as! NSDictionary let thisGuardian = dict["guardian"]! print(thisGuardian) //your code let guardianID = (child.value as? NSDictionary)?["guardian"] as? NSString print(guardianID!) } } })
*This is Swift 3 and Firebase 2.x but the concept is the same.
相关问答
更多-
Firebase按顺序获取数据(Firebase getting data in order)[2022-10-26]
既然你没有分享必要的代码,我会假设你正在做这样的事情: ref!.queryOrdered(byChild: "text").observe(.value, with: { (snapshot) in print("\(snapshot.value)") }) 在Firebase位置上执行查询时,会根据查询返回有关项目顺序的信息。 当您观察值事件时,快照将包含键,值和子级的顺序。 但是,当您将请求转换为snapshot.value属性时,必须将所有信息转换为字典。 每个孩子的关键字和价值都经历了这 ... -
从同一个巨型Firebase数据库对象中检索一些随机快照(Retrieving a few random snapshots from the same giant Firebase DB object)[2023-01-09]
按顺序执行每个请求可能不是最好的方法; 在开始下一个之前没有理由等待最后一个完成。 当然,诀窍是知道最后一个请求何时完成。 我通常只使用一个计数器: function getSomeStuff(numToGet, callback) { var obj = []; // accumulates the results var numDone = 0; // keeps track of how many of the requests have completed for (var n=0; n ... -
您可以观察位置的值以获取阵列。 let ref = FIRDatabase.database().reference().child("list") ref.observeSingleEventOfType(.Value, withBlock: { snapshot in if let objects = snapshot.children.allObjects as? [FIRDataSnapshot] { print(objects) } }) You can obs ...
-
我不确定是否可以在不知道数组是如何构建的情况下回答问题。 一个问题是For-in循环变量是一个NSFastEnumerationIterator,因此它需要向下转换为你想要它的那种“东西”。 你可能已经这样做了,这只是为了将来的参考。 话虽如此,我制作了一些代码并将其分解了一下 - 也许它会指向正确的方向。 下面的代码通过.value读入所有节点,然后遍历快照并将每个子节点存储在数组中作为FDataSnapshot。 然后代码迭代该数组并从存储在数组中的每个快照打印“guardian”。 我还包括你的代码来 ...
-
首先,你有'范围'的问题。 函数或回调内部声明的变量永远不能从该函数或回调的外部访问。 您的问题的一个解决方案可能是这样的: var results: [FIRDataSnapshot] = [] override func viewDidLoad() { super.viewDidLoad() leave.observeEventType(.Value, withBlock: { snapshot in self.results.append(snapshot.value) }) ...
-
无法将firebase快照数据检索到Javascript数组中(Unable to retrieve firebase snapshot data into Javascript array)[2022-10-18]
问题是由您订购代码的方式引起的。 执行行的顺序与您的想法不同。 如果你把它减少到这个,最容易看到这个: var firebaseRef = firebase.database().ref('Incidents'); console.log("Before database loading started"); firebaseRef.on('child_added', function(snap) { console.log("In child_added"); }); console.log("Af ... -
它看起来像你的数组从未初始化,所以self.array? 将始终跳过append 。 一种解决方案是检查数组是否存在: if (self.array?.append(math)) == nil { self.array = [math] } 有可能有更多的方法来解决这个问题,但我修改了这个问题的答案: 在Swift中将元素添加到可选数组中 更新 更简单的是在使用之前简单地创建数组: var array:[String]? var count: Int = 0 override func view ...
-
正如你已经添加了mySnap.childSnapshot(forPath: "positions").value响应mySnap.childSnapshot(forPath: "positions").value在注释中它是Dictionary Array的类型,所以键入它为[[String: Any]] 。 let positions = mySnap.childSnapshot(forPath: "positions").value as? [[String: Any]] As you have ad ...
-
尝试: var ref: FIRDatabaseReference! ref = FIRDatabase.database().reference() ref.child("users").observeSingleEvent(of: .value, with: { (snapshot) in if let snapshots = snapshot.children.allObjects as? [FIRDataSnapshot] { f ...
-
Firebase加载快照问题(Firebase loading snapshots issue)[2022-01-19]
我建议阅读使用数据列表,因为它解释了事件是如何工作的。 在这里深入研究一下你的代码是一些观察: 您正在使用ChildAdded事件和文档状态 每个现有子项触发此事件一次,然后每次将新子项添加到指定路径时再触发该事件。 因此,如果您有10个子节点,则该块将连续调用10次,每个子节点调用一次。 根据您的代码,它将尝试滚动每个不必要的子项。 有几种解决方案。 如果要加载一系列用户,则可以使用单个Value事件。 这将在所有节点中同时读取,然后您可以在节点上迭代,填充数据源(通常是数组),然后只需滚动到最后一个索引 ...